I have an application in MVC 3 and I\'m looking to add WebSockets (with fallback to Comet) to it.
I\'ve researched a bit and I found out the Comet part is pretty straigh
I've researched a bit and I found out the Comet part is pretty straightforward and I'd much rather do it myself. Just AsyncControllers and a pretty plain bit of js is all that's required to handle those long-lived ajax requests.
Sorry, it's not that easy. Different browsers behave in different ways and perform better using different techniques - XMLHttpRequest, XDomainRequest, ActiveX objects, Multpart replace, Long-Polling, Streaming. Because of this, and the fact there's no defined spec for these solutions, Comet is just a hack. Server Sent Events (EventSource API) and WebSockets have been designed from the ground up to offer the most efficient and standardised way of pushing data from server to the client, and much more importantly WebSockets have been designed for realtime bi-directional communication between a client and a server.
Now, in the case of WebSocket, things start to get dirty. I've looked at a few libraries, but they mostly seem to set up a web server (therefore needing another host, or port) of their own, and listen to ws protocol requests there. This is the case for instance for SuperWebSocket, which seemed nice at first, but had this "I'm a web server" issue (which is perfectly fine of course, but I'd rather avoid).
Windows Server 8 will natively support WebSockets. Until then you'll need to use a separate 'web server' such as XSockets or SuperWebSockets (which you've already referenced). There's also Alchemy WebSockets and Fleck.
But because Microsoft are driving SignalR forward it is most likely to get full traction and even become part of the standard ASP.NET MVC stack (it may already be planned, I'm a little behind the times with MS stuff). SignalR has WebSocket support (or has a module) and will handle fallbacks to transport mechanisms which support the user's browser.
For more information on self hosted solutions (there are a few more .NET/IIS options) check out these self hosted realtime services.
I'm very much interested in seeing how IIS scales when dealing with thousands of persistent connections - has it been re-written for Windows Server 8? How soon until you need to introduce a load balancer and horizontally scale? If that's not something you are interested in worrying about then I'd look at a hosted realtime service.