Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

signalR vs html5 websockets for asp.net MVC chat application

I am in great dilemma as to use html5 websockets or signalR for a chat we are going to integrate into our asp.net mvc3 application

My dilemmas
1.Why to use signalR if it implements longpolling?
2.Isnt longpolling bad?
3.websockets and longpolling completely different?
4.Only IIS8 supports websockets?
5.Can i save the chat data into SQL database using Html5 websockets?
6.Isnt there a workaround to make websockets work on IIS7 and higher versions(i will be using chrome browser only)
Thanks for bearing with me

like image 639
bhargav Avatar asked Feb 16 '12 08:02

bhargav


People also ask

Is SignalR better than WebSocket?

WebSockets is actually the underlying transport that SignalR uses, at least most of the time. SignalR has the ability to fall back to other ways of transporting messages, such as long-polling over HTTP. This is useful in situations where you don't have WebSockets support.

What is the difference between SignalR and WebSockets?

For most applications, we recommend SignalR over raw WebSockets. SignalR provides transport fallback for environments where WebSockets isn't available. It also provides a basic remote procedure call app model. And in most scenarios, SignalR has no significant performance disadvantage compared to using raw WebSockets.

Does SignalR use WebSockets?

SignalR uses the new WebSocket transport where available and falls back to older transports where necessary. While you could certainly write your app using WebSocket directly, using SignalR means that a lot of the extra functionality you would need to implement is already done for you.

Why we use SignalR?

SignalR can be used to add any sort of "real-time" web functionality to your ASP.NET application. Any time a user refreshes a web page to see new data, or the page implements long polling to retrieve new data, it is a candidate for using SignalR.


1 Answers

  1. Why to use signalR if it implements longpolling?

    Answer: to enable support for old browsers or to have a higher level of abstraction over data transfer implementation details. If you definitely will use the version of chrome that has a websockets support - use websockets (good explanation here).

  2. Isnt longpolling bad?

    Answer: actually it is not the best (see link above), but better than nothing for old browsers.

  3. websockets and longpolling completely different?

    Answer: they are quite different (again, see answer above), but there is smth in common for them (they both require a connection).

  4. Only IIS8 supports websockets?

    Answer: if you want to use pure .NET framework - yes, only IIS 8, and .NET 4.5. But you can use another websockets server (see workaround below).

  5. Can i save the chat data into SQL database using Html5 websockets?

    Answer: websockets is only a protocol to send data, so literally using it you cannot perform any action except of transferring data. However you could, say, have a token that will be send to server and will mean "save all previous data to DB". Or you could have more complex scenarios based on different kind of messages like inplemented in socket.io for node.js.

  6. Isnt there a workaround to make websockets work on IIS7 and higher versions(i will be using chrome browser only)

    Answer - yes, just do not use IIS, but another websockets server implementation (e.g. Fleck - has nice support for "old" browsers supporting webseckets) and run it alongside IIS as a separate process for example.

like image 99
Pavel K Avatar answered Sep 25 '22 21:09

Pavel K