I am experiencing trouble when using .NET to connect to the JSON-RPC service using WebSockets. Operating System is Windows 8 CP and XBMC is v12 on Raspberry Pi (Alpha 4, OpenElec install) and on the machine itself (Nightly d9ce56e, 20120805).
When making a Windows 8 Metro application and using the MessageWebSocket class to connect to the XBMC instance, an time-out occures. I fired up Wireshark on my machine to capture the network traffic. I can see that a GET request reaches XBMC and beïng ACK-ed. Hower I do not receive any HTTP response, and the connection is not upgraded to use the WebSockets protocol. This results in a timeout on the client, because the server disconnects the session after a certain amount of time. I tried the same with Firefox 12.0 using JavaScript and there where no issues while both are using WebSockets v13. I also captured the firefox traffic, and I found some differences, see this screenshot (click for full size):
Code:
try
{
// Make a local copy to avoid races with Closed events.
MessageWebSocket webSocket = _webSocket;
// Have we connected yet?
if (webSocket == null)
{
webSocket = new MessageWebSocket();
// MessageWebSocket supports both utf8 and binary messages.
// When utf8 is specified as the messageType, then the developer
// promises to only send utf8-encoded data.
//webSocket.Control.MessageType = SocketMessageType.Utf8;
// Set up callbacks
webSocket.MessageReceived += MessageReceived;
webSocket.Closed += Closed;
await webSocket.ConnectAsync(server);
// Code below never reaced because connection fails
_webSocket = webSocket; // Only store it after successfully connecting.
_messageWriter = new DataWriter(webSocket.OutputStream);
}
}
catch (Exception ex) // For debugging
{
WebErrorStatus status = WebSocketError.GetStatus(ex.GetBaseException().HResult);
// Here Timeout catched after ~30 secs
}
Someone has an idea where it goes wrong? Looks like XBMC does not handle the WebSocket from .NET in the right way.