TooTallNate/Java-WebSocket — Issue #42: Missing Sec-WebSocket-Key on Handshake
Author: davidb9
Created: 2011-11-22 21:39:38+00:00
State: open

I'm trying to connect to a socket.io server using https://github.com/benkay/java-socket.io.client

Just trying a simple example and output on the server is:

$ node server.js
info - socket.io started
debug - client authorized
info - handshake authorized 11501859041464584565
debug - setting request GET /socket.io/1/websocket/11501859041464584565
debug - set heartbeat interval for client 11501859041464584565
warn - websocket connection invalid: received no key
info - transport end
debug - set close timeout for client 11501859041464584565
debug - cleared close timeout for client 11501859041464584565
debug - cleared heartbeat interval for client 11501859041464584565
debug - client authorized for

I did some debug on Java-WebSocket code and what I found:

WebSocketClient.java : private void sendHandshake() throws IOException
calls: conn.startHandshake ( handshake );

WebSocket.java : public void startHandshake( HandshakeBuilder handshakedata ) throws IOException
calls: channelWrite( draft.createHandshake( draft.postProcessHandshakeRequestAsClient( handshakedata ) , role ) );

There is no information on handshakedata about Sec-WebSocket-Key
createHandshake and postProcessHandshakeRequestAsClient doesnt look for key information either so there is no Sec-WebSocket-Key field on the handshake then the socket.io server raises "warn - websocket connection invalid: received no key" and closes the connection.