代码之家  ›  专栏  ›  技术社区  ›  gvdm

信号器不返回旧协议

  •  0
  • gvdm  · 技术社区  · 6 年前

    我有一个angular 6/.netcore asp.net样板应用程序,它使用信号器允许服务器执行一些客户机代码。版本 Abp.AspNetCore.SignalR 图书馆是 3.5.0-preview3 ,它使用 Microsoft.AspNetCore.SignalR 版本 1.0.0-preview1 . 信号管理代码是ASP.NET样板文件官方模板中提供的代码。

    在使用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
    

    同样的问题也发生在边缘上:

    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是必需的)。它还写到,如果服务器不支持WebSocket(我的情况),信号器应该回退到其他协议。

    奇怪的是,尽管服务器不支持WebSocket协议,但浏览器却试图使用它。

    你有这个问题的线索吗?我可以错过什么吗?

    更新

    我将所有ASP.NET样板库升级到3.8.1,包括信号库。 这个错误没有出现,所以它是以前版本的老错误。

    现在我有了这个控制台日志:

    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!
    

    因此,一开始它告诉我们它无法通过信号器与任何协议进行连接,但随后它成功地通过了 ServerSentEvents 协议。 是连接还是不连接?

    1 回复  |  直到 6 年前
        1
  •  1
  •   aaron    6 年前

    版本 Abp.AspNetCore.SignalR 图书馆是 3.5.0-preview3 ,它使用 Microsoft.AspNetCore.SignalR 版本 1.0.0-preview1 .

    升级到 abp.aspnetcore.signal信号器 3.7.0+(当前版本:3.8.2),用于稳定版本。

    因此,一开始它告诉我们,它无法通过任何协议的信号器进行连接,但随后它成功地通过了serversentevents协议。是连接还是不连接?

    正如上面所说,它是通过 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 (“ 无法初始化任何可用的传输。 “)有点误导,因为一次只指定一个传输。