I get the following when connecting through Javascript. Am I supposed to handle the Websocket negotiation myself?
WebSocket connection to 'ws://localhost:8080/' failed: WebSocket opening handshake timed out
/var/www/instaballot/bin (staging) > php chat-server.php
New connection! (28)
Connection 28 sending message "GET / HTTP/1.1
Host: localhost:8080
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: http://127.0.0.1
Sec-WebSocket-Version: 13
DNT: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Sec-WebSocket-Key: 7Bb+2RDnFjQXd6TxQd/Hog==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
" to 0 other connections
Can you post some source code please?
It's the example code.
https://github.com/tasaif/instaballot/tree/staging
Ratchet is supposed to provide negotiation and data framing right?
Hello :)
i can write a error.
But you don't start the ws server in bin/chat-server.php.
IoServer is just for listen a socket (raw I/O), but it don't implement ws protocol.
A good example is in site : http://socketo.me/docs/hello-world
A code more true would be it :
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
8080
);
You start the server for listen the socket,
the server for manage the http Protocol
and finally the server for manage the ws protocol (it's this code who send the handshake)
(sorry for my bad english :x)
As @SaphirAngel pointed out, this step is missing from your code here
Thanks, I'll be trying this tonight.
Hello everyone,
My connection with WebSocket is not established in the only Safari 5.1.7 - I'm using Ratchet PHP WebSocket Library - I think the problem is in Ratchet library because when I'm using websocket.org codes instead of mine code in js file then WebSocket connection is established.
My Js file Websocket connection code is:
new WebSocket("ws://localhost:8080");
& WebSocket.org connection code is:
new WebSocket("ws://echo.websocket.org");
Here is the Safari header that sent to the WebSocket server:
Connection:Upgrade
Host:localhost:8080
Origin:http://sb.bindia.dk
Sec-WebSocket-Key1:1 r 7 7 3 d6922B6 1 ^
Sec-WebSocket-Key2:24 Cp7e*250dS8L 49U1
Upgrade:WebSocket
(Key3):52:4A:C3:2A:47:0F:79:B6