Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using Windows 8 with IIS8 and MVC4 to establish a websocketconnection. This works fine with Firefox, IE10 and Chrome. Safari still wont let me establish a websocketconnection. My Handlercode looks like this:

<!-- language: c# -->
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest)
{
Client client = new Client();
context.AcceptWebSocketRequest(client.HoldConnection);
}
}

The Problem is that context.IsWebSocketRequest is always false, while conntecting via Safari. My JavaScript code is a simple this.socket = new WebSocket(window.WebSocketUrl);

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
196 views
Welcome To Ask or Share your Answers For Others

1 Answer

There are two incompatible versions of the websocket protocol in use. Safari uses the original (now deprecated) Hixie variant; Firefox, IE10 and Chrome use the newer Hybi variant

Its quite possible to build a websocket server that speaks both versions but it sounds like MVC4 only supports Hybi clients.

Safari will eventually catch up. If you can't wait for this you could consider either using an alternative server which supports both websocket variants or rework your clients to poll instead (either as standard or as a fall-back when websocket connection fails).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...