I've to build a Web based chat messenger for Mobile. For that, I want my communication between server and client open so that the server can push message without any request of Client. I found SignalR and Websockets appropriate for this. But I'm not sure which one to use.
-
http://stackoverflow.com/questions/9307675/signalr-vs-html5-websockets-for-asp-net-mvc-chat-application http://stackoverflow.com/questions/9524591/net-4-5-websockets-vs-signalr?rq=1 – Damonsson Apr 11 '13 at 08:42
-
I got all the answers from this blog. http://blogs.microsoft.co.il/blogs/ranw/archive/2013/02/17/signalr-protocol.aspx Thanks all for answering my question. – Prateek Saini Apr 11 '13 at 10:11
2 Answers
Under the hood, SignalR uses Web Sockets, Long Polling, Server Sent Events or Forever frames, based on what is supported on the client and the browser, to enable real-time features in applications. You should consider using it to avoid compatibility issues and to get additional features that can be used to develop real-time applications. You can refer to the following documentation for more details:

- 1,007
- 1
- 8
- 14
-
I'm new to SignalR. When I run application previously, it showed SSE(serverSentEvents) in the "Connection:", but now its showing Connection:Keep-alive and its using XHR. I'm using Firebug plugin in Mozilla. – Prateek Saini Apr 11 '13 at 09:07
-
You can determine the transport being used through the transport property in connection or hub connection after the connection has been started. SignalR tries to use Web Sockets but if both the server and the client do not support it, it fall-backs to other transports. You can also turn on logging by $connection.myhub.logging = true to see which transport is being used. – Abhishek Nanda Apr 11 '13 at 18:56
the answer is it really depends. it depends on your scale, i am not saying that SignalR scales poorly. it`s about support of SignalR client libraries on mobiles.
we have used signalr for a while and faced many headatches and then fall back to raw websockets.
according to my experience:
1- SignalR dose not support Websocket on xamarin clients. (because it uses types in System.Net.WebSockets and this namespace is not available in any PCL profiles) and they are not planning to add it any time soon (i`v contacted them on github). and as you might no other solutions like (long polling or forever frame and ... consume 5 times more memory than WebSockets).
2- it provides a Pathetic control over the actual transport which will put you in a big trouble on mobile devices when dealing with Doze mode, screen lock etc, ... . (there are workarounds for these situations but they are basically very dirty).
as conclusion, i think for mobile if you have time use raw System.Net.WebSockets which is implemented in mono (according to what James james montemagno said) and main .net. otherwise you can use Microsoft.WebSockets nuget package which is discontinued however.

- 1,896
- 19
- 48