SignalR 不会退回到旧协议
SignalR not falling back to older protocols
我有一个 Angular 6/.NETCore ASP.NET 样板应用程序,它使用 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 我可以看到 Windows Server 2008 R2 支持 SignalR,尽管 IIS 7 不支持它(需要 8)。它还写道,如果服务器不支持 WebSocket(我的情况),SignalR 应该回退到其他协议。
奇怪的是,浏览器正在尝试使用 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
协议成功。
连接不连接?
The version of the Abp.AspNetCore.SignalR
library is 3.5.0-preview3
, which uses Microsoft.AspNetCore.SignalR
version 1.0.0-preview1
.
升级到 Abp.AspNetCore.SignalR
3.7.0+(当前:3.8.2)以获得稳定的发布版本。
So at first it tells that it fails connecting though SignalR with any protocol, but then it succeeds with the ServerSentEvents protocol. Is it connecting or not?
正如它所说,它是使用 ServerSentEvents
传输连接的。你可以看到为什么 here:
abp.log.debug('Cannot start the connection using ' + signalR.HttpTransportType[transport] + ' transport. ' + error.message);
if (transport !== signalR.HttpTransportType.LongPolling) {
return start(transport + 1);
}
error.message
(“无法初始化任何可用的传输。”)有点误导,因为一次只指定了一种传输。
我有一个 Angular 6/.NETCore ASP.NET 样板应用程序,它使用 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 我可以看到 Windows Server 2008 R2 支持 SignalR,尽管 IIS 7 不支持它(需要 8)。它还写道,如果服务器不支持 WebSocket(我的情况),SignalR 应该回退到其他协议。
奇怪的是,浏览器正在尝试使用 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
协议成功。
连接不连接?
The version of the
Abp.AspNetCore.SignalR
library is3.5.0-preview3
, which usesMicrosoft.AspNetCore.SignalR
version1.0.0-preview1
.
升级到 Abp.AspNetCore.SignalR
3.7.0+(当前:3.8.2)以获得稳定的发布版本。
So at first it tells that it fails connecting though SignalR with any protocol, but then it succeeds with the ServerSentEvents protocol. Is it connecting or not?
正如它所说,它是使用 ServerSentEvents
传输连接的。你可以看到为什么 here:
abp.log.debug('Cannot start the connection using ' + signalR.HttpTransportType[transport] + ' transport. ' + error.message);
if (transport !== signalR.HttpTransportType.LongPolling) {
return start(transport + 1);
}
error.message
(“无法初始化任何可用的传输。”)有点误导,因为一次只指定了一种传输。