Identifying the SignalR Transport Medium

Identifying the SignalR Transport Medium

ASP.NET SignalR  simplifies the process of implementation of  real-time applications. Though it started with ASP.NET web application, it can be consumed by other .NET Client Application , Windows Phone or even Windows 8 application.  One of the key components of SignalR is Transport Medium, by which it communicate.  Websocket is the first preference!  When there is an availability of WebSocket, SignalR uses it as transport medium, otherwise it falls back to other transports dependents on the clients. Following are the four transport medium available for the SignalR

  • WebSocket
  • Server-Sent Events
  • Forever Frame
  • Long Polling

When we have the browsers as client, SignalR check the browser compatibility and takes the decision accordingly.

SignalR Transport Medium

You can refer this link to see how you can start working with SignalR and build a basic chat application http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-getting-started-with-signalr-20

Assuming that you have a SignalR application, and running it on browser.  Let’s have a look how to identify the transport medium.  When the application is running on IE11,  open the Console from the Browser Developer Toolbar, and execute the following command.

$.connection.hub.transport

This will return you an object for transport with named “webSockets” .  This is because of the browser supports the WebSocket, so SignalR picks this up as its first preference of transport.

Transport in IE11

If you move to any older version of Internet Explorer, such as IE 9 or IE8, you will find the transport medium has changed and it picks up from the fall  back transport medium.

Transport in IE9 and IE8

Similarly, like Internet Explorer, you can try to execute this command for other browser to get the know what kind of medium is used by the SignalR.

You can also enable the log  to get the transport and other details.

$.connection.hub.logging = true;

Once the logging is enabled, you can view the connections along with other details as show in below image.

SignalR Logging Enabled

DON'T MISS OUT!
Subscribe To Newsletter For your Daily Development Tips and Tricks  

 Best Tips & Tricks on Microsoft Technology Platform 

Invalid email address
We promise not to spam you. You can unsubscribe at any time.
Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

One Comment to “Identifying the SignalR Transport Medium”

Comments are closed.