Home > other >  The service side python websocket connection to the network can not be established
The service side python websocket connection to the network can not be established

Time:11-29

Question:
The service side python websocket client connect to the network can not be established

Environment:
Server: WAMP
Operating system: WIN10
Web front end websocket is used to establish a library of JS: reconnecting - websocket
A server-side websocket using python library: Pywss

Port mapping has a network port 80 through 37609 port is mapped to the network, the browser can access the address,
However, page is always unable to establish connection with server ...
Front-end websocket here initialization parameter has been set up the network IP and port 37609, the service side is also open to monitor 0.0.0.0 and port 37609,

Try many schemes, hope the predecessors to give debugging, where is the problem?

The existing information:
1. In the network firewall rules of inbound and outbound rules are joined the allowed 80376 09 port communication
2. IP and port 37609, Telnet the network can be connected, show the HTTP/1.1 200 OK... After, although displays lost connection to the master; It's no problem for me to Ping the IP
3. When the machine debugging communication can be successful communication, front-end websocket parameter set to localhost IP or native IP (also can be connected to the computer in the LAN)
4. The web site can normal visit , database access, is cannot be established with the server connection
5. This is the web page websocket debugging information: websocket connection to 'ws://4 x, XX XXX. 161:37609/view_tool' failed: Error during the websocket handshake: Unexpected response code: 404
Debugging information and network diagram:


PS: Apache Settings once the Require all granted, this is also what exquisite?

CodePudding user response:

Question is out of the Apache this, you need to set up a reverse proxy, but the principle is not very clear,
In the apache HTTPD. Under the conf file, load the following two modules, cancel the previous # comments
LoadModule proxy_module modules/mod_proxy. So
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel. So
Again at the end of the text to add proxy Settings:
ProxyPass ws://127.0.0.1:37609/view_tool
ProxyPassReverse WSS://127.0.0.1:37609/view_tool

127.0.0.1 should not need to be modified, 37609 is your server listening port,/view_tool is your ws path,
Can now be connected, but not like the connection process soon, and then connected to the originally will immediately notify the front page, now still have some delay, actually already connected, study again,
Reference articles:
Method through the Apache access WebSocket configuration
Apache reverse proxy Settings

CodePudding user response:

Can also be in the HTTP - vhosts. Conf Riga proxy statements (seems to be more stable)
ProxyPass/view_tool "" "" ws://127.0.0.1:37609/view_tool "
ProxyPassReverse "/view_tool" "WSS://127.0.0.1:37609/view_tool"
Reference - Apache configuration WebSocket agent
  • Related