移动到应用程序负载均衡器后面的 AWS fargate 后 SignalR 握手问题。
在我使用 nginx 在 EC2 实例上运行之前,在遵循此建议后运行良好; ASP.NET Core 中的 SignalR 在 Nginx 后面。但由于某些原因,我们不得不将其移至 AWS fargate 并使用 Aws 应用程序负载均衡器 (ALB)。现在我们无法让 signalR 启动并运行。该服务有一个工作正常的 REST api。
而且我仍然可以切换回旧的基础设施,这就像一个魅力。
从颤振应用程序我得到这个:
flutter: [Signals] Connection Restarting after http error - 404 - Not Found
flutter: [Signals] Connection Closed - Cannot start a connection that is not in the 'Disconnected' state.
flutter: [Signals] [Transport] SEVERE: : Server returned handshake error: 'Handshake was canceled.'
flutter: [Signals] [Hub] SEVERE: Server returned handshake error: 'Handshake was canceled.'
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: type 'GeneralError' is not a subtype of type 'Error'
0 ServerSentEventsTransport.connect.<anonymous closure>
package:signalr_client/server_sent_events_transport.dart:73
1 _rootRunUnary (dart:async/zone.dart:1192:38)
2 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
3 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
4 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
5 _DelayedData.perform (dart:async/stream_impl.dart:594:14)
6 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:710:11)
7 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:670:7)
8 _rootRun (dart:async/zone.dart:1180:38)
9 _CustomZone.run (dart:async/zone.dart:1077:19)
10 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
11 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
12 _rootRun (dart:async/zone.da<…>
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: Server returned handshake error: 'Handshake was canceled.'
flutter: [Signals] [Transport] SEVERE:Connection disconnected with error 'Server returned handshake error: 'Handshake was canceled.''.
flutter: [Signals] [Hub] SEVERE: Connection disconnected with error 'Server returned handshake error: 'Handshake was canceled.''.
flutter: [Signals] Connection Closed - Server returned handshake error: 'Handshake was canceled.'
和这个:
flutter: [Signals] [Transport] SEVERE: 2020-05-28 14:10:11.870554: Failed to start the transport 'HttpTransportType.WebSockets': WebSocketException: Connection to 'https://api.com:0/hubs/people?id=[id]&access_token=[Token] was not upgraded to websocket
它看起来类似于我们在 nginx 中解决的问题,但我认为 AWS ALB 应该默认处理它。如果我在本地运行该服务,它工作正常。
我们用:
- 使用这个 signalR 客户端颤振:https ://github.com/soernt/signalr_client
- API:目标框架:
- netcoreapp2.1 Docker:mcr.microsoft.com/dotnet/core/aspnet:2.1-alpine
- Microsoft.AspNetCore.SignalR.Protocols.MessagePack:1.0.0
提前致谢