码迷,mamicode.com
首页 > Web开发 > 详细

Why SignalR does not use WebSockets?

时间:2016-11-02 17:15:22      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:bbb   sock   soc   host   exp   asp   request   mpi   switch   

Why SignalR does not use WebSockets?

 

 

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 

Why SignalR does not use WebSockets?

标签:bbb   sock   soc   host   exp   asp   request   mpi   switch   

原文地址:http://www.cnblogs.com/micro-chen/p/6023426.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!