Remote Application (the App) is stored at a remote web server with static IP address and available via http/https protocol. The App uses Laravel framework.
Clients are stored at different local ubuntu devices (RaspberryPi), has internet access with dynamic ip. This clients are responsible for hardware managing. Currently, this clients use pure php and some bash scripts.
Clients interacts with the App in the following ways:
Both 1st and 2nd tasks could be resolved by http request.
But for the 1st task is better to use some event based solution: the app trigger events, only after that clients shall start doing tasks with immediately.
For web applications we can use websocket. But our devices has no graphic interface, just ubuntu server with command line interface.
Are there any event's based, web socket's like solutions or ideas how these clients could interact with the App?
After looking for solutions I've found out that these kind of tasks could be resolved by using web hooks.
But, local devices don't have direct public entrance.
This issue could be resolved by using ssh tunnel between local clients and some remote server with public access. To establish this tunnel you have to run following command on your local client:
ssh -R 8010:localhost:8020 -nvNT remoteusername@remotehost
8020 - local client port to receive web-hooks, 8010 - remote server port, -nvNT - set of options to get real-time log.
During the time of this tunnel is running all requests to remotehost:8010 will be handled by local client at it's localhost:8020 port.
So then, the app could push web-hooks trough the tunnel to the client.
Bellow are a few useful links:
https://hackernotes.io/simple-recipe-forwarding-webhooks-local-development-environment/
https://www.davidokwii.com/how-to-ssh-into-server-that-has-no-public-ip-from-anywhere/
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-16-04