SignalR不会退回到较旧的协议

时间:2018-08-08 08:50:16

标签: javascript .net-core aspnetboilerplate asp.net-core-signalr

我有一个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开发过程中,一切正常。

现在,我已在IIS 7服务器附带的Windows Server 2008 R2上发布了该应用程序。该应用程序启动,但是在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不支持SignalR(要求8)。还写道,如果服务器不支持WebSocket(我的情况),SignalR应该回退到其他协议。

奇怪的是,即使服务器不支持浏览器,浏览器仍在尝试使用WebSocket协议。

您对此问题有任何线索吗?我可能会丢失一些东西吗?

更新

我将所有ASP.NET样板库都升级到了3.8.1,包括SignalR库。 该错误未显示,因此它是以前版本的旧错误。

现在我有此控制台日志:

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协议就可以成功。 是否连接?

1 个答案:

答案 0 :(得分:1)

  

const worldToLocal = new THREE.Matrix4().getInverse(cube.parent.matrixWorld); const poseMatrix = new THREE.Matrix4(); poseMatrix.makeRotationFromQuaternion(globalQuaternion); poseMatrix.setPosition(globalPosition); poseMatrix.multiplyMatrices(worldToLocal, poseMatrix); poseMatrix.decompose(cube.position, cube.quaternion, {}); 库的版本为Abp.AspNetCore.SignalR,它使用3.5.0-preview3版本Microsoft.AspNetCore.SignalR

升级到1.0.0-preview1 3.7.0+(当前:3.8.2)以获得稳定的发行版。

  

因此,起初它告诉它无法通过SignalR与任何协议进行连接,但是随后通过ServerSentEvents协议成功进行连接。是否连接?

如前所述,它使用Abp.AspNetCore.SignalR传输器进行连接。您可以了解为什么here

ServerSentEvents

abp.log.debug('Cannot start the connection using ' + signalR.HttpTransportType[transport] + ' transport. ' + error.message); if (transport !== signalR.HttpTransportType.LongPolling) { return start(transport + 1); } (“ 无法初始化任何可用的传输。”)有点误导,因为一次仅指定一个传输。