I'm trying to write a websocket server using OWIN/Katana. I'm following the sample laid out here: http://aspnet.codeplex.com/sourcecontrol/latest#Samples/Katana/WebSocketSample/WebSocketServer/Startup.cs
And now my client side code:
var connection = new WebSocket('ws://localhost:5000/game', 'kmud');
connection.onopen = function () {
connection.send('Ping');
};
The problem I'm having is that when this code is executed, the connection reaches the server just fine, and the server MOSTLY sends the right stuff back, but there's one problem: The protocol returned from the server is wrong. It's always blank.
Here's the request:
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:Upgrade
Host:localhost:5000
Origin:null
Pragma:no-cache
Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits
Sec-WebSocket-Key:7Q3r81ZhvtCSmbbUnVRUXA==
Sec-WebSocket-Protocol:kmud
Sec-WebSocket-Version:13
Upgrade:websocket
User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
And then the response:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Server: Microsoft-HTTPAPI/2.0
Sec-WebSocket-Protocol:
Connection: Upgrade
Sec-WebSocket-Accept: u/0CCzacjw8KKJd0UjKW0xuJFU4=
Date: Thu, 12 Mar 2015 19:14:02 GMT
Note how the protocol is blank in the response. My browser has a problem with this and tosses an exception:
WebSocket connection to 'ws://localhost:5000/game' failed: Error during WebSocket handshake: 'Sec-WebSocket-Protocol' header value '' in response does not match any of sent values
So I tried many types of different protocols; including '', null, 'soap', and ['soap', 'json'], but nothing worked. Whenever I examined the context within the server, the protocol is reported as an array with a single element containing an empty string.
What am I doing wrong here?