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.

  1. 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.
  2. 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
  3. 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.



2 Answers 2


Your idea will indeed work (this is exactly how services like Dataplicity are implemented). Note that if you were to create a web site yourself it will not be necessarily more secure. You'll just shift hacking-related risks from your RPi to your website.


You can use asp.net core e.g. Run kestrel server on pri and build your request pipeline as you wish. Also you able to create razor pages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.