【发布时间】:2018-08-08 08:50:15
【问题描述】:
我有一个 Angular 6/.NETCore ASP.NET Boilerplate 应用程序,它使用 SignalR 允许服务器执行一些客户端代码。 Abp.AspNetCore.SignalR 库的版本是3.5.0-preview3,它使用Microsoft.AspNetCore.SignalR 版本1.0.0-preview1。
SignalR管理代码是ASP.NET Boilerplate官方模板中自带的。
在使用 IIS Express 的 Visual Studio 开发过程中一切正常。
现在我已经在 Windows Server 2008 R2 上发布了该应用程序,它附带了一个 IIS 7 服务器。应用程序启动但在 Chrome 控制台中我看到此错误:
signalr.min.js:13 WebSocket connection to 'ws://MY-HOSTNAME:21021//signalr failed: Error during WebSocket handshake: Unexpected response code: 400
signalr.min.js:13 Error: Failed to start the connection. undefined
Edge 也出现同样的问题:
Starting connection using WebSockets transport abp.js (350,1) Error:
Failed to start the connection. undefined signalr.min.js (13,25649)
SCRIPT12008: SCRIPT12008: WebSocket Error: Incorrect HTTP response.
Status code 400, Bad Request
Here 我可以看到 SignalR 在 Windows Server 2008 R2 中受支持,即使它在 IIS 7 中不受支持(需要 8 个)。还写到 SignalR 应该回退到其他协议,以防服务器不支持 WebSocket(我的情况)。
奇怪的是,浏览器尝试使用 WebSocket 协议,即使服务器不支持它。
你对这个问题有任何线索吗?我可能错过了什么吗?
更新
我将所有 ASP.NET 样板库升级到 3.8.1,包括 SignalR 库。 错误没有出现,所以是以前版本的老bug。
现在我有了这个控制台日志:
Starting connection using WebSockets transport
Failed to start the connection: Error: Unable to initialize any of the available transports.
Cannot start the connection using WebSockets transport. Unable to initialize any of the available transports.
Starting connection using ServerSentEvents transport
Information: SSE connected to http://MY-HOST:21021//signalr?asdasdasd
Connected to SignalR server!
Registered to the SignalR server!
所以一开始它告诉它通过 SignalR 与任何协议连接失败,但随后它通过ServerSentEvents 协议连接成功。
是连接还是不连接?
【问题讨论】:
-
Quote: ASP.NET Core 支持的任何服务器平台。使用 IIS 时,WebSockets 传输需要 IIS 8.0 或更高版本,在 Windows Server 2012 或更高版本上。所有平台都支持其他传输
-
升级到 Abp.AspNetCore.SignalR 3.7.0+(当前:3.8.2)。
标签: javascript .net-core aspnetboilerplate asp.net-core-signalr