Signalr WebSockets无法在Windows服务器2012 R2 + IIS 8.5上启用websocket协议,但适用于本地开发机器(Win 10)

时间:2017-05-09 19:35:36

标签: windows websocket server signalr

Signalr WebSockets无法在启用了websocket协议的Windows服务器2012 R2 + IIS 8.5上运行,但适用于本地开发机器(Win 10)。

两种设置均符合: https://www.iis.net/configreference/system.webserver/websocket

服务器(Websockets不工作) -Windows 2012 R2 Standard -IIS 8.5 - 启用了Web地址 -Client Chrome版本58 64位(在服务器上本地运行,就像开发机器一样 - 消除负载均衡器或网络问题) 信号返回TryWebSockets:false(SSE,longpolling和Forever Frame可以工作)

本地开发机器(WebSockets正在运行) -Windows 10 -IIS 10.0.10586.0 -Client Chrome版本58 64位 信号返回TryWebSockets:true

Web.config有:

<system.web>
        <httpRuntime targetFramework="4.5"...

<compilation defaultLanguage="c#" debug="true" targetFramework="4.6.2">

抓住稻草:

  1. 添加<appSettings><add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/> 〜没有变化本地作品/服务器没有

  2. 重新安装信号器包 〜没有变化本地作品/服务器没有(参考表格: SignalR won't use Websocket protocol even though I have the protocol installed in windows 8

  3. 尝试升级到Signalr 2.2.2表2.2.1 〜没有变化本地作品/服务器没有

  4. 服务器重启 〜没有变化本地作品/服务器没有

  5. 测试更改为<httpRuntime targetFramework="4.6.2"... 〜没有变化本地作品/服务器没有

  6. 客户端明确设置为使用websockets

    $。connection.hub.start({transport:'webSockets'},function(){                 console.log('connection started WebSockets!');             完成(function()

  7. 。)

    〜没有变化本地作品/服务器没有

    已检查的装配体 https://forums.asp.net/p/1872743/5263876.aspx

1 个答案:

答案 0 :(得分:0)

原来是缺少applicationhost.config中的一行,需要更新以包含:

var ExpirationDate = new Date(); ExpirationDate.setDate(ExpirationDate.getDate() + 400); document.cookie = 'eucookie=2;' + ExpirationDate.toUTCString();