kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
Apache License 2.0
768 stars 273 forks source link

"unknown server protocol version" #6

Closed shlomiw closed 11 years ago

shlomiw commented 11 years ago

Hi, I was using WebSocket4Net lib for receiving MtGox bitcoin streaming data: "ws://websocket.mtgox.com/mtgox"

It was working very good until yesterday. Then I started getting the following Error: "unknown server protocol version" I believe MtGox changed something in their API and probably some of the response headers are missing (such as the version field). I've tried to contact them but I didn't get a reply yet.

But - I'm able to connect the above WebSocket via javascript in chrome, and I receive the streaming data normally.

Is it possible for WebSocket4Net to connect the way chrome does? (maybe less restrictive with the response headers).

Thanks in advance, Shlomi

shlomiw commented 11 years ago

I'm now debugging the source-code, it's not a version issue. I get "HTTP/1.1 400 Bad Request" in the response. I'm trying to figure it out because I'm using the same ws address as in the javascript code.

shlomiw commented 11 years ago

I believe I found what's wrong. WebSocket4Net sends in the handshake request headers: "Origin: websocket.mtgox.com", but if I imitate the browser headers and change it to "Origin: http://websocket.mtgox.com" (can be changed in the WebSocket constructor), suddenly it start working...

kerryjiang commented 11 years ago

Ok, I'll check the spec in the rfc 6455...

shlomiw commented 11 years ago

thanks!