Answer the question
In order to leave comments, you need to log in
WebSockets, only works on localhost?
Good day, %username%.
Given:
A php daemon that processes requests and a client located on the same machine.
The daemon uses all possible connections on port 8081 (Socket bind successfully on 0.0.0.0:8081 .).
Option 1:
The client uses a local address to connect ( ws://localhost:8081/ ).
Result:
Handshake occurs, the onopen event is fired on the client. All subsequent requests from both the client and the server are processed normally.
Option 2:
The client uses an external address to connect ( ws://176.х.х.х:8081/ ).
Result:
Handshake occurs, the onopen event is called on the client. Neither the server nor the client receives any more requests.
I've been fighting for the second day, thoughts are over ...
Answer the question
In order to leave comments, you need to log in
Thank you all, the question is removed =) The case was in the incorrect calculation of payload length.
Headers from client:
Response from server:
GET / HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: 176.х.х.х:8081
Origin: 176.х.х.х
Sec-WebSocket-Key: aUOMe5Zs+5lnPNjAiPp/Kw==
Sec-WebSocket-Version: 13
Cookie: PHPSESSID=5226a026e3626569bba468bc27bc3bab
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: /NYJ3OVdOzEkA62igWeFGHmVwR4=
Sec-WebSocket-Version: 13
Origin: 176.х.х.х:8081
Host: 176.х.х.х
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question