S
S
Skpd2012-02-29 18:38:08
PHP
Skpd, 2012-02-29 18:38:08

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

5 answer(s)
S
Skpd, 2012-03-01
@Skpd

Thank you all, the question is removed =) The case was in the incorrect calculation of payload length.

I
iStyx, 2012-03-01
@iStyx

So, show me the code. And then somehow all this is ephemeral.

I
iStyx, 2012-03-01
@iStyx

Does the client pass the header exactly Origin?

S
Skpd, 2012-03-01
@Skpd

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.х.х.х

P
Pavlo Ponomarenko, 2012-03-01
@TheShock

Try turning off the firewall

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question