Websocket will not connect from a remote server

I have a webpage for controlling a raspberry pi thermostat and am having difficulty trying to get websites to work with a remote client. It seems to work fine when on the local network. I obviously missed something (and probably something basic), but I can’t understand what it is.

The local ip is 192.168.1.134. The web page (served by the Apache server) has a URL http://192.168.1.134:8010/thermostat.html. Some javascript is launched on the page, which then tries to connect to the main pi program using websockets via ws://192.168.1.134:9000. (server on pi runs libwebsockets). A websocket appears and it seems to be working fine. Then I tried to connect through a remote client (cell phone where Wi-Fi is disconnected) from http:\\23.239.99.99:8010\thermostat.html. The html / js files load in order, but the web socket is trying to connect to uri ws:\\23.239.99.99:9000, and this is a flemish.

As far as I can tell, NAT seems to be configured correctly:

name           ext     ext    protocol    int     int     ip addr     interface
               port    port               port    port
               start   end                start   end

Thermostat3     8010   8010   TCP        8010   8010    192.168.1.134   eth3.1  
Thermostat5     8000   8000   TCP/UDP    80     80      192.168.1.134   eth3.1  
Thermostat_ws   9000   9000   TCP/UDP    9000   9000    192.168.1.134   eth3.1  

I checked, and the router does not have any firewalls, nor does my modem. I did not set the firewall to pi (I checked and there is no odd iptables rule there). Does anyone know what I am missing?

--- EDIT ---

. -, , . , 9000, ?

+4
4

Apache 0.0.0.0, .

+2

, , ( ): http://www.whatsmyip.org/port-scanner/

. ws 8010, , . , Advanced Web Client, .

+1

. . WebSocket ( nodejs ws), , ws://yourip:port, http://yourip:port. , , -, .

, . , , , pi WebSocket , .
 , WebSocket. WebSocket , , . . ...
https, .
. nodejs express ( https nginx/apache https) . - POST /api/? Id = 0 , , , node.
, .

0

, Apache

0

Source: https://habr.com/ru/post/1678084/


All Articles