【问题标题】:Unhandled Exception: None of the transports supported by the client are supported by the server未处理的异常:客户端支持的传输均不受服务器支持
【发布时间】:2022-02-09 03:48:19
【问题描述】:

我在从客户端连接 SignalR 时遇到问题。我收到此错误“服务器不支持客户端支持的传输。”。它也应该 GET 请求而不是 log 说它是一个 POST 请求。

代码:

final httpConnectionOptions = HttpConnectionOptions(
      /*httpClient: WebSupportingHttpClient(logger,
          httpClientCreateCallback: _httpClientCreateCallback),*/
      logger: logger,
      //logMessageContent: true,
      //transport: HttpTransportType.ServerSentEvents,
      //skipNegotiation: true,
    );
    _hubConnection = HubConnectionBuilder()
        .withUrl(
          _serverUrl + formData,
          options: httpConnectionOptions,
          //transportType: HttpTransportType.ServerSentEvents,
        )
        .withAutomaticReconnect()
        //.withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000])
        .configureLogging(logger)
        .build();
    _hubConnection.onclose(({error}) => connectionIsOpen = false);

日志:

I/flutter (31934): Starting HubConnection.
I/chatty  (31934): uid=10154 1.ui identical 11 lines
I/flutter (31934): Starting HubConnection.
I/flutter (31934): Starting connection with transfer format 'TransferFormat.Text'.
I/chatty  (31934): uid=10154(com.ci.radico.radico) 1.ui identical 11 lines
I/flutter (31934): Starting connection with transfer format 'TransferFormat.Text'.
I/flutter (31934): Sending negotiation request: <host>/signalr/negotiate?<data>&negotiateVersion=1
I/chatty  (31934): uid=10154() 1.ui identical 11 lines
I/flutter (31934): Sending negotiation request: <host>/signalr/negotiate?<data>&negotiateVersion=1
I/flutter (31934): HTTP send: url '<host>/signalr/negotiate?<data>&negotiateVersion=1', method: 'POST' content: '' content length = '0' headers: '{ content-type: text/plain;charset=UTF-8 }, { X-Requested-With: FlutterHttpClient }'
I/chatty  (31934): uid=10154(com.ci.radico.radico) 1.ui identical 11 lines
I/flutter (31934): HTTP send: url 'https://ps360ordersapi.ci-private-ase.p.azurewebsites.net/signalr/negotiate?<data>&negotiateVersion=1', method: 'POST' content: '' content length = '0' headers: '{ content-type: text/plain;charset=UTF-8 }, { X-Requested-With: FlutterHttpClient }'
I/flutter (31934): Failed to start the connection: None of the transports supported by the client are supported by the server.
I/chatty  (31934): uid=10154() 1.ui identical 11 lines
I/flutter (31934): Failed to start the connection: None of the transports supported by the client are supported by the server.
I/flutter (31934): HubConnection failed to start successfully because of error 'None of the transports supported by the client are supported by the server.'.
I/chatty  (31934): uid=10154() 1.ui identical 11 lines
I/flutter (31934): HubConnection failed to start successfully because of error 'None of the transports supported by the client are supported by the server.'.
E/flutter (31934): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: None of the transports supported by the client are supported by the server.
E/flutter (31934): 

【问题讨论】:

    标签: flutter signalr signalr.client azure-signalr signalr.net-client


    【解决方案1】:

    对于Azure,必须明确启用网络套接字。

    【讨论】:

    • 这是错误的,您链接的问题特定于使用 Blazor。 OP 没有使用 blazor,因为 blazor 会为您管理 SignalR 连接,如果您正在创建自己的 SignalR 连接,则您不会遇到与 Blazor 相同的代码路径。
    • WebSockets 部分是部分准确的。您应该在 Azure 应用服务站点上显式启用 WebSocket,但从技术上讲,它不是必需的(除非颤振客户端不支持其他传输)。
    • 我将编辑部分正确的答案。
    • 我尝试从 Azure 应用服务为请求的 API 主机启用 WebSocket。但它无法工作。 “除非颤振客户端不支持其他传输”是什么意思?
    • 由于 AngularJS 的 Web 应用程序已经正常工作,客户端需要进行哪些更改。
    猜你喜欢
    • 1970-01-01
    • 2020-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-28
    • 1970-01-01
    • 2021-10-26
    相关资源
    最近更新 更多