Sunday 31 March 2013

Introduction to SignalR

SignalR is an asp.net library that we can use to add real-time functionality to our applications. Under the hood it uses HTML5 websockets and various other old techniques as a fallback option to support realtime communication between client and server. We will explore all these in detail in this signalR blog.

In this context real-time means pushing information from server to client as and when it happens or is available with the server.

Damian Edwards at Microsoft and one of the creators of SignalR describes it as "Incredibly simple real-time web for .NET". Well, we will definitely explore simplicity of this library in upcoming posts on this blog.

SignalR started of as a side project and was later on included into ASP.NET out of the box and fully supported in release "ASP.NET and Web Tools 2012.2".

So now SignalR is a part ASP.NET family.


There are many scenarios in today's world, be it an Enterprise or social media etc, where real time has almost become a prerequisite. I have personally worked on many applications where we have to constantly fetch updated data  from the server and display to the clients. We would end up either giving a refresh button(really old school :) ) or creating the page as auto refresh with meta tags or do some timely polling to server from client with some ajax calls.

SignalR has come to your rescue in such scenarios(and many more..). It provides you the capability to actually establish a persistent connection between client and server using web-sockets (if available) and lets server communicate with client seamlessly.

SignalR is a real-time, persistent connection abstraction over HTTP for .NET. I believe what Microsoft's intent in creating such a library is to let you write code against SignalR classes that abstracts out the low level  details of managing client connections.

We all know that Websockets is an upcoming standard and is only supported in new browsers like IE 10, chrome 16+, hence SignalR has a beautiful support for fallback to our old school techniques.



SignalR will check of web-sockets support in the client browser. If it is not present it will fallback to other techniques like Server Sent Events, Forever Frames or Long Polling. I will describe about all these in some of my upcoming posts as this post is more focused upon SignalR.

SignalR is open source and is available on GitHub here.