SignalR : know your transport

I just recently started using SignalR. I had the time to explore this new framework in the last couple of months and use it in a recent work engagement for a proof of concept.There has been a wide acceptance for SignalR – not without a reason.It’s very easy to set up and code, supports WebSockets if Client and Server both support the transport. This has made real-time programming easy and fun, plus in this new age of rich internet applications this can be almost in any context.

Secondly ,the SignalR support is tremendous – it’s open sourced and supported by Microsoft. The MS developers of the product do a tremendous job of answering questions on premier .net QA forums like Stack Overflow. There are several examples on the web available on how to set up and get SignalR working with your project including GitHub where SignalR is hosted. However I would like bring in some observations where I had some in-claritythe beginning. SignalR basically supports four transports, employs graceful degradation based on the negotiation between the client and the server. The four transports are:

  1. WebSockets
  2. Server Sent Events
  3. Forever Frame
  4. Long polling

The WebSockets transport is the most sought after transport for real-time programming because it offers a bi-directional communication as opposed to other transports giving you the maximum performance. Although SignalR can be made to work with .net framework 4.0, however WebSockets will not get used as a transport if you are using a web server version lower than IIS 8.0 .This is an important aspect to realize considering certain browsers like Chrome support WebSockets. It’s good to run Fiddler and see what happens in order to understand if SignalR negotiated a WebSockets transport or not.

GET http://localhost:2592/signalr/hubs 200 OK (application/x-javascript)GET http://localhost:2592/signalr/negotiate?_=1359546909252 200 OK (application/json)

GET http://localhost:2592/signalr/connect?transport=serverSentEvents&connectionId=d66299e6-196f-4f17-a11f-191c8dfd84d1&connectionData=%5B%7B%22name%22%3A%22stocktickerhub%22%7D%5D&tid=9

200 OK (text/event-stream)

POST http://localhost:2592/signalr/send?transport=serverSentEvents&connectionId=d66299e6-196f-4f17-a11f-191c8dfd84d1

200 OK (application/json)

Here I am running this application from Visual studio 2010, .net framework 4.0 and Chrome release 24.0.1312.56 m as a browser which does support WebSockets transport. So the point is,  it is not sufficient if the browser supports WebSockets , the server needs to have support for it as well. As of now , in order to run SignalR in production with IIS , at minimal you must have IIS 8.0 and .net framework 4.5 . ASP.NET 4.5 and IIS 8 include low-level WebSockets support and not the previous versions.

In a second experiment there is a request going into IIS 6.0 , on the local network where SignalR is hosted with .net framework 4.0 and Chrome as the browser –

GET 200 OK (application/json)

GET 200 OK (application/json)

200 OK (application/json)

200 OK (application/json)

Well , now long polling got negotiated because the request is considered Cross domain , as of now neither WebSockets nor ServerSentEvents are supported under Cross domain.

Any of the above 4 transports could work depending on the context of your application. However it’s important that you run Fiddler or some other similar tool to know what transport got negotiated and whether client and server both support it.

Thanks to this question by Hemang Dave on Stack Overflow, helped me arrive at some conclusions.

Happy SignalR programming !

  1. #1 by nintendo 3ds roms free download on August 2, 2013 - 10:30 pm

    Hey People ,fantastic blog post . your best 3DS game ?

  2. #2 by kid crafts on September 24, 2013 - 8:56 am

    Howdy! I’m at work browsing your blog from my new iphone 4!
    Just wanted to say I love reading through your blog and look forward to all your posts!
    Carry on the great work!

  3. #3 by SEO on March 9, 2014 - 5:06 am

    Excellent confident analytical attention pertaining to fine detail and can foresee problems before these people happen.

  4. #4 by on November 27, 2015 - 5:37 am

    こんにちは!私が尋ねるはずと考えたのだが、しかししかし、私はこれはちょっとオフトピックです知っています。リンクまたは多分ゲスト|あなたはの取引交換に興味があるオーサリング ポストまたはその逆?私と同じ多くのサイト アドレス トピックをあなたと私は考えるとして、我々は非常にお互いに利益を得ることができます。場合は興味が送るまでお気軽に私あなたがすることが起こる。あなたからの便りを楽しみにしています! 極上経由でブログ!
    国内即発 2015 春夏

  5. #5 by on November 27, 2015 - 5:38 am

    グッド サイト、仕事|}続行非常に良い {仕事を続けていくまで。 あなたの時間をありがとう !。
    正規通販新作2015種類 国内即発

  6. #6 by on November 27, 2015 - 5:43 am

    I ことができませんでした |コメントご遠慮レジスト。 非常によく書かれました!
    国内即発 アクセサリー

  7. #7 by on November 27, 2015 - 5:44 am

    whoahこの 私は大好き 読んで勉強あなたブログは 壮大な素晴らしいです。 後処理| キープ滞在! 検索狩猟 、 あなたは理解してあなたが知っていますこのため、情報、あなたができる | 大きく助け援助それら。
    店舗品質ー価格絶対のお買い得 商品到着後レビュー記載でプレゼント

  8. #8 by on November 27, 2015 - 5:46 am

    …私の心| 近くに近くに これは話題です! ここであなたの連絡先の詳細はし​​かしありますか?
    国内即発 幸福を運んで来る

  9. #9 by on November 27, 2015 - 5:48 am

    ウェイクール!いくつかの非常は有効なポイント!極めて| |非常に|また、実際には非常にも良いです。
    送料無料市場 一部予約販売

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: