Reputation: 115
I've been trying to setup a Unity3D component which negotiates a WebSocket Connection with a Javascript Client.
I have a threaded TCPListener (c#) which handles the HTTP request and attempts to negotiate the Handshake, though it seems to be silently failing. The client closes the connection shortly after I send my response.
I've been following the instructions on this site: http://deusty.blogspot.com/2010/09/websocket-draft-76-algorithm-example.html
Here is the Sockets Log
ws://localhost:3000/serverStart
Start Time: Wed Aug 24 2011 23:32:54 GMT+0100 (GMT Daylight Time)
t=1314225174926 [st= 0] +REQUEST_ALIVE [dt=1038]
t=1314225174926 [st= 0] +SOCKET_STREAM_CONNECT [dt= 999]
--> url = "ws://localhost:3000/serverStart"
t=1314225174927 [st= 1] +PROXY_SERVICE [dt= 0]
t=1314225174927 [st= 1] PROXY_SERVICE_RESOLVED_PROXY_LIST
--> pac_string = "DIRECT"
t=1314225174927 [st= 1] -PROXY_SERVICE
t=1314225174927 [st= 1] +PROXY_SERVICE [dt= 0]
t=1314225174927 [st= 1] PROXY_SERVICE_RESOLVED_PROXY_LIST
--> pac_string = "DIRECT"
t=1314225174927 [st= 1] -PROXY_SERVICE
t=1314225174927 [st= 1] HOST_RESOLVER_IMPL [dt= 2]
--> source_dependency = {"id":455371,"type":7}
t=1314225175925 [st= 999] -SOCKET_STREAM_CONNECT
t=1314225175926 [st=1000] WEB_SOCKET_SEND_REQUEST_HEADERS
--> GET /serverStart HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: localhost:3000
Origin: null
Sec-WebSocket-Key1: 52 18 5w7 9 9 2c
Sec-WebSocket-Key2: a2PA tG8 1>7242<6(yj7I2
\x78\x15\xbc\x75\x2d\x54\x3b\xea
t=1314225175926 [st=1000] SOCKET_STREAM_SENT
t=1314225175963 [st=1037] SOCKET_STREAM_RECEIVED
t=1314225175963 [st=1037] WEB_SOCKET_READ_RESPONSE_HEADERS
--> HTTP/1.1 101 WebSocket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Origin: null
Sec-WebSocket-Location: ws://localhost:3000/serverStart
Sec-WebSocket-Protocol: webpad
\x20\xc3\xc3\xf6\xad\xd2\x76\x63\x48\x86\x0c\xd2\xa6\xb1\x06\x72
t=1314225175963 [st=1037] SOCKET_STREAM_RECEIVED
t=1314225175963 [st=1037] SOCKET_STREAM_RECEIVED
t=1314225175964 [st=1038] -REQUEST_ALIVE
I'm generating the response using the following algo
response = MD5( bitpack(
Key1(numbers only / num of spaces),
Key2(numbers only / num of spaces),
RequestBody))
Any help you can give would be much appreciated?
Upvotes: 1
Views: 1821
Reputation: 1273
Opera will (if you enable websockets in opera:config) log the reason for refusing the connection in the error console, which is helpful for debugging where the problem is (if it's the challenge or a typoed header or wrong origin etc).
But I suspect the real problem here is that you're testing from file:/// and Chrome doesn't like that.
Upvotes: 2
Reputation: 297
I discussed this with some people on the #WhatWG channel on Freenode (so I can't take the credit) and we were wondering why the origin is null. Maybe Chrome has a security implementation in place that disallows connections from null origins (e.g. using file:///).
A suggestion was made to try Opera 11.00 or higher to see if Chrome has a bug here or some security model that disallows this.
Upvotes: 0