Question

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

Was it helpful?

Solution

  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.

OTHER TIPS

SignalR can support websockets if IIS and your browser support this, if not it uses longpolling. Using SignalR will save you a lot of time reinventing the wheel, they have proven that you can create a good chat website with it.

enter image description here

Hope it will solve all your queries.

4. Only IIS8 supports websockets?

SignalR supports IE < 8 with Json2.js. Just get it with Nuget install-package json2

Make sure you add a reference to json2.js BEFORE signalR.js

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top