|
|
|
|
@ -401,27 +401,18 @@ class ChatProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
throw StateError('Cannot open SignalR hub: chat login token is null/empty. Call getUserAutoLoginTokenSilent() first.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NOTE: build the url with Uri so every query value is properly encoded.
|
|
|
|
|
// Never hand-concatenate the JWT - unencoded characters silently break the
|
|
|
|
|
// negotiate request and the server answers 401 (which surfaces as the
|
|
|
|
|
// confusing "https://host:0/... was not upgraded to websocket" error,
|
|
|
|
|
// see comment on [buildHubConnection]).
|
|
|
|
|
final Uri hubUri = Uri.parse(URLs.chatHubUrlChat).replace(queryParameters: <String, String>{
|
|
|
|
|
"UserId": "${login?.userId}",
|
|
|
|
|
"source": "Desktop",
|
|
|
|
|
"access_token": token,
|
|
|
|
|
});
|
|
|
|
|
final String hubUrl = _urlWithExplicitPort(hubUri);
|
|
|
|
|
|
|
|
|
|
// Send the token as a real `Authorization: Bearer` header too.
|
|
|
|
|
// signalr_netcore uses `accessTokenFactory` for BOTH the /negotiate call and
|
|
|
|
|
// the websocket handshake on mobile (query strings are only used on web),
|
|
|
|
|
// so without this the websocket upgrade request is unauthenticated -> 401.
|
|
|
|
|
final HttpConnectionOptions httpOp = HttpConnectionOptions(
|
|
|
|
|
transport: HttpTransportType.LongPolling,
|
|
|
|
|
skipNegotiation: false,
|
|
|
|
|
logMessageContent: true,
|
|
|
|
|
logMessageContent: false,
|
|
|
|
|
accessTokenFactory: () async => token,
|
|
|
|
|
requestTimeout: 30000, // package default is only 2000ms
|
|
|
|
|
requestTimeout: 30000,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final HubConnection hub = HubConnectionBuilder()
|
|
|
|
|
|