Problems with SignalR handshake after moving to AWS fargate behind an application load balancer.
Before I had it running on a EC2 instance with nginx which worked fine after following this advice; SignalR in ASP.NET Core behind Nginx. But because of stuff we had to move it to AWS fargate and use Aws Application Load balancer (ALB). Now we can´t get signalR up and running. The service has a REST api which works fine.
And I can still switch back to the old Infrastructure and that works like a charm.
From the flutter app I get this:
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.'
And this:
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
It looks similar to the problem we solved in nginx, but I thought AWS ALB should handle it by default. If i run the service locally it works fine.
We use:
- Flutter with this signalR client: https://github.com/soernt/signalr_client
- API: TargetFramework:
- netcoreapp2.1 Docker: mcr.microsoft.com/dotnet/core/aspnet:2.1-alpine
- Microsoft.AspNetCore.SignalR.Protocols.MessagePack: 1.0.0
Thanks in advance