expose ESP32 WebServer to public without router setup or third party service

michox
Posts: 8
Joined: Tue Jun 02, 2020 4:38 pm

expose ESP32 WebServer to public without router setup or third party service

Postby michox » Mon Jun 29, 2020 6:25 pm

Hello,

I have to expose my esp32 to the public. The esp would post its local IP to a database on a webserver from where it then can be found. I am not able to set up the router because it has to work on public networks and without any third-party service such as ngrok. I have a webserver available and I want to make both HTTP requests and WebSocket connections.

Unfortunately, I was not able to find how to set this up in such a way.
Could somebody be so kind as to point me in the right direction?

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: expose ESP32 WebServer to public without router setup or third party service

Postby PeterR » Tue Jun 30, 2020 12:51 am

Never say never but not possible without router access and/or you have the uplink.
How is an external client going to address you when all you have is a 'local' class C address?
You need port forwarding or a 'less local' IP address (direct, remove the router) to be found.
Now maybe you could do something with a remote host. You register with the host and the host acts as you're proxy.
You would have to poll the 'host' however (because the host cannot reach you).
Turn it around, host the website on a public server & post your data...
Sounds like a job for AWS man!
& I also believe that IDF CAN should be fixed.

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: expose ESP32 WebServer to public without router setup or third party service

Postby tommeyers » Tue Jun 30, 2020 2:16 am

Dyndns
IT Professional, Maker
Santiago, Dominican Republic

michox
Posts: 8
Joined: Tue Jun 02, 2020 4:38 pm

Re: expose ESP32 WebServer to public without router setup or third party service

Postby michox » Tue Jun 30, 2020 8:30 am

PeterR wrote:
Tue Jun 30, 2020 12:51 am
Never say never but not possible without router access and/or you have the uplink.
How is an external client going to address you when all you have is a 'local' class C address?
You need port forwarding or a 'less local' IP address (direct, remove the router) to be found.
Now maybe you could do something with a remote host. You register with the host and the host acts as you're proxy.
You would have to poll the 'host' however (because the host cannot reach you).
Turn it around, host the website on a public server & post your data...
Sounds like a job for AWS man!
Thanks for your answer. The esp32 should be capable of getting the publicIP of the router isn't it? now it would just have to tell the router to forward posts that are coming onto the public IP on a specific port to the esp IP. Why is that not possible?
Could I use MQTT and Azure for this? With the esp32 as a publisher of readings and at the same time a subscriber to configuration changes of the Azure database?
Also would it be possible to establish a P2P connection with somebody accessing the website on the public server? maybe using peerJS?
It's critical to get real time life readings. I know MQTT is quite fast but P2P would be even better.

I want to host my own DDNS with my database. The question is how do I actually access the ESP32 with that information?

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: expose ESP32 WebServer to public without router setup or third party service

Postby PeterR » Tue Jun 30, 2020 10:42 am

The esp32 should be capable of getting the publicIP of the router isn't it?
Typically yes, if you know the router's API. Most routers have a page displaying public IP and some provide that data in an easy to use API.
now it would just have to tell the router to forward posts that are coming onto the public IP on a specific port to the esp IP. Why is that not possible?
It is possible. It is how the router works & why you can watch Netflix whilst junior plays CoD.

Your question was:
The esp would post its local IP to a database on a webserver from where it then can be found.
This is not possible.
The internet works using a set of routable codes & masks. Your local address e.g. 192.168.80.2 is similar to saying your home address is 'number 15', which street? which town etc.
The way the router works is by forwarding your requsts using its own public IP (because if I sent my Amazon order out with my address as 'number 15' its not going to work well) but using a specific port and remembering the translation between port used and local IP address. On return of data (to the public router address) the router is then able to work out who the request is for and forwards to the local address.
The crux point is that the local address is always requesting. Ok there are public 'send to everypone' protocols but we will ignore multicast for the moment.
Could I use MQTT and Azure for this? With the esp32 as a publisher of readings and at the same time a subscriber to configuration changes of the Azure database?
Absolutely, or any other cloud system.
Also would it be possible to establish a P2P connection with somebody accessing the website on the public server? maybe using peerJS?
It's critical to get real time life readings. I know MQTT is quite fast but P2P would be even better.
You are not going to get 'real time' in 'real time'. You can get measurements at precise intervals but in arrears, like video buffering. P2P support depends on the server.
You will find MQTT easier to get running and more widely supported.
& I also believe that IDF CAN should be fixed.

michox
Posts: 8
Joined: Tue Jun 02, 2020 4:38 pm

Re: expose ESP32 WebServer to public without router setup or third party service

Postby michox » Tue Jun 30, 2020 2:16 pm

PeterR wrote:
The esp32 should be capable of getting the publicIP of the router isn't it?
Typically yes, if you know the router's API. Most routers have a page displaying public IP and some provide that data in an easy to use API.
now it would just have to tell the router to forward posts that are coming onto the public IP on a specific port to the esp IP. Why is that not possible?
It is possible. It is how the router works & why you can watch Netflix whilst junior plays CoD.

Is it possible to do this without setting up the router from a third party device?
Your question was:
The esp would post its local IP to a database on a webserver from where it then can be found.
This is not possible.
The internet works using a set of routable codes & masks. Your local address e.g. 192.168.80.2 is similar to saying your home address is 'number 15', which street? which town etc.
The way the router works is by forwarding your requsts using its own public IP (because if I sent my Amazon order out with my address as 'number 15' its not going to work well) but using a specific port and remembering the translation between port used and local IP address. On return of data (to the public router address) the router is then able to work out who the request is for and forwards to the local address.
The crux point is that the local address is always requesting. Ok there are public 'send to everypone' protocols but we will ignore multicast for the moment.
thanks that clarified a lot
Could I use MQTT and Azure for this? With the esp32 as a publisher of readings and at the same time a subscriber to configuration changes of the Azure database?
Absolutely, or any other cloud system.
Also would it be possible to establish a P2P connection with somebody accessing the website on the public server? maybe using peerJS?
It's critical to get real time life readings. I know MQTT is quite fast but P2P would be even better.
You are not going to get 'real time' in 'real time'. You can get measurements at precise intervals but in arrears, like video buffering. P2P support depends on the server.
You will find MQTT easier to get running and more widely supported.
ok looks like MQTT is the way to go then... Thanks!

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: expose ESP32 WebServer to public without router setup or third party service

Postby PeterR » Tue Jun 30, 2020 7:27 pm

Is it possible to do this without setting up the router from a third party device?
You would have to run this software from a server and have your local device register with the server. End users would do the same. The server address would be the public point of access because you cannot change your router (EDIT) & no one can see you hidden behind your router (in fact many routers will try their best to hide you from worms etc).*
EDIT: Because you say that you cannot configure you're router
A server based MQTT broker allows you to register on a topic and publish etc. Your router is still doing the port/local address translation this time with a websocket. Other tech is possible.

Reliable transmission/reception requires a connection based socket. Your device does not have a public address & so others (EDIT) cannot make a connection to you. You can make a connection with someone outside your environment - your router will translate & essentially extend your address for you. The server acts as the man in the middle hence the 'Broker' name.
EDIT: Outside your local network

* Be careful. In some corporate environment most ports will be shut down so even MQTT might not work.
& I also believe that IDF CAN should be fixed.

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 104 guests