I have been doing a lot of research and I think I may have a way to talk to my RPi over the web without having to to any port forwarding and opening up my home wifi to potential dangers. Please give any feedback on your thoughts if this would work or not.
- I will create a website that will host rest services. These services will be used to capture device readings to display on the web. It will also host services that can be used to send notifications to users if there is a problem.
- I will create a python client on the RPi that will connect to the website to post any data to using a small flask server calling the rest services. Each remote RPi will have its own unique Id to post data to
- I will create a small client application that will sit on the RPi and ping the server at a determined interval (1 second or so, that is do be determined) to listed for commands that may be cued for the RPi (like set GPIO high/low). The client will execute the commands, then return the results back to the server rest services.
I think this will work. The sticking point may be the websocket connections and the ping. If I have to many clients it may bog down my server, but I am hoping that since the commands will be lightweight JSON commands, and the commands will be all the same, this will not be a problem. I will also have a very small database of user settings on the RPi for thresholds that if breached would send an alert to the central server to notify the user that a limit has been breached and open a websocket port as well to listen for immediate commands returned from the server as well.
Does this seem like it would work? Does anyone have any other suggestions (or even links) to communicating with an RPi over websockets that has a listening client? Is there a better way to do this without port forwarding?
I am not looking for a solution, just architectural insight and any input from anyone that may have done this or knows of some links.