XSockets vs SignalR

Sunday, October 06, 2013 10:45 PM 8

This document contains a comparison table for XSockets vs SignalR.

Below you find the comparison table and comments on features we think might need some explanation. This list will have many features that does not exists in SignalR, and we might have missed some features in SignalR that does not exists in XSockets. If so give us a hint and we will add those features to the list.

The source for SignalR features and functions is http://www.asp.net/signalr

 

Feature

XSockets

SignalR

WebSockets server-side

Yes, Always

Yes, but only if you have .NET 4.5 and Windows 2012 Server or Windows 8 and later.

 

Since XSockets always has websocket (or full-duplex) support you can run the server on anything that runs Mono/.NET and TCP/IP. So the full XSockets server can run on anything from RaspberryPI to a real server.

The fact that you need not only .NET 4.5 but also 2012 server/Win8 is probably the reason for SignalR´s nice transports. They gracefully fallback to SSE, For ever frame and longpolling.

Fallback

Yes, but it requires .NET 4.5

Yes,

Server-Sent Events (All but IE)

Forever Frame (IE only)

Longpolling

 

XSockets only have Websockets or longpolling since there is no need for SSE when the server always deliver websockets regardless of where it runs. Longpolling using Async ASP.NET WebAPI

SignalR’s transports mechanism is nice! They have solved it in a really good way. However, our first thought was why have SSE at all when the browsers supporting SSE also support websockets? Well, since SignalR does not have websockets if you do not fulfill the server side demands (.NET 4.5, 2012 server/Win8) they had to implement SSE to not have just a longpolling framework.

Binary Support

Yes

No

Binary Support with Metadata

Yes

No

 

This means that you can pass custom objects together with the binary data to attach for example file information etc. See http://xsockets.net/docs/4/binary-data

 

WebRTC

Yes

No

 

XSockets has a controller for webrtc and also a javascript API.

 

Peer-2-Peer

Yes

No

 

When using a WebRTC capable browser you can also use XSockets to communicate between clients peer-to-peer sending messages that never touch the XSockets server.

 

Server-side state

Yes

No

 

By having state we always know everything about each client connected. The advantage of this is that we easily can use lambda expressions to target subset of clients.

Our opinion is that if you do not have state you do not have realtime. A message should NEVER be sent to a client that does not need it.

SignalR has no state by design. This means that you can't target specific clients when sending data. SignalR has solved this by using something called groups. So that is a kind of state. As far as we know you can add connections to a group, for example “Male” and then send messages to all clients in the group… But what happens if you want to send to all clients within the range of x km from y? Or if you want to target only males between 25 - 30 yrs that has red hair… You can't do it easily.. And if you can do it at all it will be a mess!

The advantage of not having state is that you should get higher speed when sending (broadcasting). But the downside of that is that you might send data to clients not interested, or even worse.. the client is not allowed to see the data. Groups avoids this in SignalR.

Publish/Subscribe

Yes

No

 

The server will know what each and every client subscribes to. You can easily target a subset of subscribers by using lambda expressions since XSockets have state see the academy http://xsockets.net/academy/xva-01-05-statepubsub

There are projects around SignalR offering pub/sub for example https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/wiki

RPC

Yes

Yes

 

XSockets supports RPC as of version 4.0. The combination of RPC with server-side state is a powerful feature. See http://xsockets.net/academy/xva-01-06-staterpc

 

DataSync

Yes

No

 

DataSync is a complex topic, but this sample shows that it is pretty easy to implement in XSockets http://xsockets.net/academy/xva-02-02-datasyncbasic

 

jQuery depencency

No

Yes

 

XSockets does not have a depency to jQuery. This enables XSockets to be more lightweight and also makes it easier to use with for example AngularJS http://xsockets.net/academy/xva-08-01-angularjs-basic

The SignalR team is working on removing the jQuery dependency and should be fixed in SignalR v3

Self-Hosted

Yes

Yes, via Owin

   

Not really getting how something can be self-hosted when there is a dependency to Owin.

Azure-hosted

Yes

Yes

Amazon-hosted

Yes

Yes

WindowsService

Yes

Yes, via Owin

Hosting in general

XSockets full server implementation can run on any device with Mono/.NET and TCP/IP. This means that pretty much anything running Linux, Unix, Windows can run the XSockets server with full-duplex communication.

The server can certainly be put into many places, but to use websockets as transport is will need 2012 Server/Win8 and .NET 4.5

C# Client

Yes

Yes

JavaScript Client

Yes

Yes

Angular provider

Yes

Probably

   

Do not of any public angular provider, but there should be several on github.

Client side WebSockets

Yes

With Win8+ and .NET 4.5 - See http://www.asp.net/signalr/overview/getting-started/supported-platforms

JavaScript Proxy

No

Yes

   

SignalR has a nice auto generated proxy. If you go tohttp://yourapp:port/SignalR/Hubs

you will see the proxy generated for you which is cool

Offline Messages

Yes

No

 

XSockets uses an in-memory storage so that you can store messages that arrive when a client is offline and then push the messages to the client when he/she reconnects

 

Server side storage

Yes

No

 

XSockets has a generic static in-memory storage (Repository<TK,T>) for storing simple data-structures without using a database. You can see it being used in the basic data-sync demo http://xsockets.net/academy/xva-02-02-datasyncbasic

 

Plugin based architecture

Yes

No

 

Almost everything in XSockets is a plugin and you can replace most of them yourself… If you want a custom serializer build one, if you need a new protocol for communication build one… If you want to intercept the xsockets pipeline build a plugin… Build a custom controller… Its a plugin and so on..

SignalR does not have plugins but they support IoC and let you configure your container of choice

Custom Serializer

Yes

No

 

As already stated almost everything in XSockets is a plugin and you can replace most of them yourself… If you want a custom serializer build one. By default XSockets uses JSON.NET, but you can replace it with your own favorite by just implementing the interface!

SignalR have a very strong dependency to JSON.NET. David Fowlers (Microsoft/SignalR) own words is "I wouldn't bother trying. We have a deep dependency on JSON.NET and we've even removed this extensibility in the next release. Sorry."in this post on StackOverflow

Scaling

Yes

Yes

 

XSockets-servers can live in a cluster where all other servers are siblings and this will boost the performance and scale in a great way. Since XSockets scale over sockets instead of a backplane, we do not get a bottle neck in the same way as a SQL-server would.

SignalR can use Azure, Redis, SqlServer to scale out…http://www.asp.net/signalr/overview/performance-and-scaling/scaleout-in-signalr

Reduce message size

Yes

Yes

 

If you use the serializer shipped with XSockets you can use the DataMember attribute on properties to get shorter names in serialization.

SignalR lets you set JsonProperty attributes on properties so that the size of the message will be smaller. On the client you can the remap the short message with a contract. Pretty nice when hunting performance!

Passing state from client to server

Yes

Yes

 

XSockets has state during the connections lifetime and XSockets knows everything about each client. If you want to change a property on the clients connection just do it… XSockets has state!

The big difference here is that with XSockets you send the state once and then the server knows about it… In signalr you send the state-object every time you do a server side call...

In SignalR you can use the state object to attach data on every call to the server.

Text below copied from ASP.NET:
Note: This mechanism for persisting state is not intended for large amounts of data, since everything you put in the state or Clients.Caller property is round-tripped with every method invocation. It's useful for smaller items such as user names or counters.

Longrunning Hub/Controller

Yes

No

 

You can create longrunning controllers in XSockets. These controllers is singleton plugins that can't be connected to from any client. But the longrunning controller can perform tasks and notify “real” controllers when something happens. See a simple example here http://xsockets.net/academy/xva-02-05-clockcontroller

 

Intercepting the pipeline

Yes

Yes

SSL/TLS

Yes

Yes

Controls frames

Yes

No

 

The WebSocket protocol specification defines Ping and Pong frames that can be used for keep-alive, heart-beats, network status probing, latency instrumentation, and so forth. XSockets.NET contains server side API's that lets you constructs and pass such frames from the server to the client.

SignalR is an abstraction on top of transports such as websockets. There is no way to send control frames for all that we know. If you have other info about this please let us know and the section will be updated.

Cross controller/hub communicaton

Yes

?

Custom protocols

Yes

No

 

This is one of the most important things in a real-time framework. If the browsers talks RFC6455 (websockets) and you have a TCP/IP enabled device/unit these should ofcourse be able to talk to each other even though they speak different languages (protocols). In XSockets you can within minutes create a custom protocol and connect anything to talk to anything.

A very simple example of doing so: http://xsockets.net/academy/xva-05-02-customprotocol

 

Conclusion

We found that the biggest and most clear difference frameworks their ability to transport information on different network protocols as well as how and when the data is passed to a client. We all know that AJAX can mean that we have thousands of clients hammering a server asking for information when nothing has happen.

If a framework broadcasts data to all clients connected we have just inverted the AJAX issue and now we have a server hammering clients with information they do not want.

At a first glance XSockets and SignalR look alike, but the differences are huge!

The two most important things is that XSockets can talk cross protocol and have state by default. You can add custom protocols very easy, and also target different clients with simple lambda expressions. This enables communication between all devices that supports TCP/IP.