Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.Js + Socket.IO vs SignalR vs C# WebSocket Server

I currently have a TCP server application written in .Net that receives and submits messages to clients. I am looking at building a web application so need the communication layer.

I have built a Node.JS + Socket.IO app which connects to my TCP server and then pushes communication to the web application and all works fine.

I have just read about SignalR as an alternative to keep it in the .Net stack.

However I have also found that I could write a C# Websocket Server, a basic demo here

I assume that this basic server is what SignalR is but obviously with a lot more functionality in it?

What I'm trying to decide is do I just append my current TCP application with a Websocket server or do I go down a separate SignalR or Node.js route? Out of interest how does a SignalR application run, is it as a Windows service, console app or IIS service?

like image 424
Jon Avatar asked Mar 02 '12 17:03

Jon


People also ask

Should I use WebSockets or SignalR?

ASP.NET Core SignalR is a library that simplifies adding real-time web functionality to apps. It uses WebSockets whenever possible. For most applications, we recommend SignalR over raw WebSockets. SignalR provides transport fallback for environments where WebSockets isn't available.

Which is better Socket.IO or WS?

Both WebSocket vs Socket.io are popular choices in the market; let us discuss some of the major Difference Between WebSocket vs Socket.io: It provides the Connection over TCP, while Socket.io is a library to abstract the WebSocket connections. WebSocket doesn't have fallback options, while Socket.io supports fallback.

Is Socket.IO efficient?

js - Using socket.io is broadcasting the same efficiency as sending a message to every client - Stack Overflow.


2 Answers

SignalR is like Socket.IO in that it supports transport negotiation/fallback. It is a framework and not a server, so you need to host it on a server of some sort. We have hosts for ASP.NET, OWIN (e.g. Kayak) and self-host, so you can run it in your own process easily, e.g. a Windows service.

SignalR has supported clients for browsers (JS), .NET, Windows Phone 7 and Silverlight. There are also contributed clients for things like iOS, Mono Touch, etc.

SignalR will give you a much higher level API than raw sockets which is its big advantage, allowing you to do things like "RPC" from server to clients in a broadcast (or targeted) fashion.

like image 158
Damian Edwards Avatar answered Sep 21 '22 11:09

Damian Edwards


Other implications

I've used both technologies and work on both sides of the .NET / node stacks.

  1. Although I prefer the node side these days, if you only work in .NET, SignalR is the obvious choice. Conversely, if you build all your projects in node I would go with socket.io or sockjs. If your scope is narrow enough that you don't need to worry about fallbacks and that sort of thing, I'd recommend checking out ws module since its simpler and lighter on your dependencies. In the past, socket.io has been a pain on Windows due to install issues with node-gyp failing to install native dependencies (node-gyp requires many configuration steps that vary wildly depending on which version of Windows you have but is required for C++ native built modules). UPDATE This Windows bit is not so much relevant anymore thanks to windows-build-tools.
  2. If you have a load balancer and are planning on running SignalR, you are going to need to setup SQL or Redis as a backplane to bypass the load balancer. You will have similar issues to deal with on the socket.io side and there are [multiple supported methods][1] (1 of which is redis also).

Update - removed jquery info since it is no longer applicable

like image 30
cchamberlain Avatar answered Sep 22 '22 11:09

cchamberlain