Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By Focak
#46457 Hi ,

I made websocket server on my local network.
So if I use local IP address for websocket, then I can connect to server from my local network but I can not connect from public network.

ESP8266WebServer server(80);
WebSocketsServer webSocket = WebSocketsServer(81);

var wsUri = "ws://192.168.1.129:81/";

and if I use dns host for websocket then I can connect to server from public network but I cannot connect from local network

ESP8266WebServer server(80);
WebSocketsServer webSocket = WebSocketsServer(81);

var wsUri = "ws://dns-host:81/";

is there any way to make websocket server which I can connect same time from local network also from public network ?
User avatar
By Focak
#46464 Yes I forwarded ports 80 and 81 to my local IP. In both scenarios I can open webserver page from both local and public ip.
But websocket can not connect if I use dns host in script for websocket:

var wsUri = "ws://dns-host:81/";

router does not have nat loopback so when I try to connect from local
network browser load script with var wsUri = "ws://dns-host:81/";
but webcosket cannot connect .
User avatar
By martinayotte
#46471 Did you tried it while been really outside from your local network ?
(I have this kind of issue with my ISP modem, where routing is refused when done from inside my local network)
Did you tried with your external IP instead of "dns-host" ? (could be a local DNS issue)