Why SignalR does not use WebSockets?

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

As you probably know SignalR supports multiple transports. The favor one and most powerful one is of course WEBSOCKET transport.
Unfortunately this transport cannot be always used in any infrastructure. When your application is started the client side of SignalR will check what transports are supported.
Interestingly there is a similar check at the server side.

For example, if you see following request

POST /Daenet.MySpy/signalr/signalr/send?transport=foreverFrame&connectionId=cd17bb01-23de-4181-97da-6514b9bbb58e HTTP/1.1

which is responded by following response, it means that web socket transport is not supported. If infrastructure does not support streaming SIgnalR will use fallback transport. In a case of Internet Explorer this will be foreverFrame as shown above.
To be sure that the server is not the problem, try to find out the request like following one:

GET /Daenet.MySpy/signalr/signalr/connect?transport=webSockets&connectionId=cd17bb01-23de-4181-97da-6514b9bbb58e&connectionData=%5B%7B%22name%22%3A%22trackerhub%22%7D%5D&tid=6 HTTP/1.1

If this request has failed with error 500 it means that the server does not support websockets. In this specific case server means the server (IIS) supports WebSockets, but ASP.NET version of your application which hosts SignalR does not support websockets.
It sound wired, buiit is not. If the server does not support WebSockets (for example Windows Server 2008) you will never get error 500 back. The client will switch to fallback transport automatically. This error is related to ASP.NET.
To fix it you need following in the web.config:

<system.web>

    <compilation debug="true" targetFramework="4.5"/>
   <httpRuntime targetFramework="4.5"/>
   <pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>

 

http://localhost/MySpy/signalr/signalr/connect?transport=webSockets&connectionId=829cc336-a32c-457a-b539-fca7744fda09&connectionData=%5B%7B%22name%22%3A%22trackerhub%22%7D%5D&tid=7


Posted Oct 25 2012, 12:12 AM by Damir Dobric
Filed under:

Comments

Damir Dobric Posts wrote Why SignalR does not use WebSockets Part II?
on 03-30-2013 14:22

If you notice that signalR does not use websockets you might first take a look on this post. But if this

DamirDobric wrote Why SignalR does not use WebSockets Part II?
on 03-30-2013 14:28

If you notice that signalR does not use websockets you might first take a look on this post. But if this

Carla wrote re: Why SignalR does not use WebSockets?
on 12-06-2013 2:22

The primary deefirfnce between this approach and an actual browser cache is best explained by comparing the words  cache  and  storage .  All kinds of Web stoage are managed in part based on a fixed size allocated per domain . Your browser's cache is managed for you:  things are algorithmically optimized by expellig older, less used items.  Local storage, on the other hand is just the storage part  it contains no cache facilities.  You can use a different name every time you change your css files, but even then nothing will expell your old entries unless you write something to manage that as well.  In the process, you can very easily wind up wasting a valuable and finite resource.  In most cases it is better to let the browser manage this on your behalf.  One thing that can help a bit is to use a CDN (cloudflare offers a free one that I have had good experiences with) and, where possible promote sharing of these resouces across many domains as these will reduce latecy, load on your server and icrease your liklihood of cache hits for all.

developers.de is a .Net Community Blog powered by daenet GmbH.