Open ikudeljnjak opened 6 months ago
Further thing I've detected:
there are two requests sent to the hub, a POST request and a GET request. The POST request has authorization headers needed, but the GET request doesn't - and this request returns 401.
I would say this is the problem.
Connection upgrade issue any solution for this
i have working on signalr 8 and get the same error please help me if you have any solutions
`message: Starting HubConnection. message: null
[2024-04-30 16:26:37.151692 SignalR LatLng] error: null message: Starting connection with transfer format 'TransferFormat.Text'. message: null
[2024-04-30 16:26:37.202843 SignalR LatLng] error: null message: Sending negotiation request: https://realtime.****.net/hub/negotiate?negotiateVersion=1 message: null
[2024-04-30 16:26:37.229015 SignalR LatLng] error: null message: HTTP send: url 'https://realtime.*******.net/hub/negotiate?negotiateVersion=1', method: 'POST' content: '' content length = '0' headers: '{ content-type: text/plain;charset=UTF-8 }, { X-Requested-With: FlutterHttpClient }, { authorization: Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImY3NTZjNmJjLTEwYTQtNGE0Ny1jM2IwLTA4ZGM1Yzc2Y2Q1OCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkRyaXZlciIsImV4cCI6MTcxNDQ5ODM2MywiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NzA4Ny8iLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MDg3LyJ9.fuxYpVypm3nzA15qMwbO9wrmszNV48cpKlHom--o6A8 }, { Authorization: Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImY3NTZjNmJjLTEwYTQtNGE0Ny1jM2IwLTA4ZGM1Yzc2Y2Q1OCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkRyaXZlciIsImV4cCI6MTcxNDQ5ODM2MywiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NzA4Ny8iLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MDg3LyJ9.fuxYpVypm3nzA15qMwbO9wrmszNV48cpKlHom--o6A8 }' message: null
E/gralloc4(10329): Empty SMPTE 2094-40 data E/gralloc4(10329): Empty SMPTE 2094-40 data E/gralloc4(10329): Empty SMPTE 2094-40 data [2024-04-30 16:26:38.186607 SignalR LatLng] error: null message: Selecting transport 'HttpTransportType.WebSockets'. message: null
[2024-04-30 16:26:38.195162 SignalR LatLng] error: null message: (WebSockets transport) Connecting message: null
[2024-04-30 16:26:38.205808 SignalR LatLng] error: null message: WebSocket try connecting to 'wss://realtime.***.net/hub?id=5eftxqkWA1EFz7jv6lDMtQ&access_token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImY3NTZjNmJjLTEwYTQtNGE0Ny1jM2IwLTA4ZGM1Yzc2Y2Q1OCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkRyaXZlciIsImV4cCI6MTcxNDQ5ODM2MywiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NzA4Ny8iLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MDg3LyJ9.fuxYpVypm3nzA15qMwbO9wrmszNV48cpKlHom--o6A8'. message: null
[2024-04-30 16:26:38.228177 SignalR LatLng] error: null message: WebSocket connected to 'wss://realtime.***.net/hub?id=5eftxqkWA1EFz7jv6lDMtQ&access_token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImY3NTZjNmJjLTEwYTQtNGE0Ny1jM2IwLTA4ZGM1Yzc2Y2Q1OCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkRyaXZlciIsImV4cCI6MTcxNDQ5ODM2MywiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NzA4Ny8iLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MDg3LyJ9.fuxYpVypm3nzA15qMwbO9wrmszNV48cpKlHom--o6A8'. message: null
[2024-04-30 16:26:38.230771 SignalR LatLng] error: null message: The HttpConnection connected successfully. message: null
[2024-04-30 16:26:38.231496 SignalR LatLng] error: null message: Sending handshake request. message: null
[2024-04-30 16:26:38.239084 SignalR LatLng] error: null message: (WebSockets transport) sending data. String data of length 32. Content: '{"protocol":"json","version":1}'. message: null
[2024-04-30 16:26:38.240471 SignalR LatLng] error: null message: Using HubProtocol 'json'. message: null
E/flutter (10329): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: WebSocketException: Connection to 'https://realtime.********.net:0/hub?id=5eftxqkWA1EFz7jv6lDMtQ&access_token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImY3NTZjNmJjLTEwYTQtNGE0Ny1jM2IwLTA4ZGM1Yzc2Y2Q1OCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkRyaXZlciIsImV4cCI6MTcxNDQ5ODM2MywiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NzA4Ny8iLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MDg3LyJ9.fuxYpVypm3nzA15qMwbO9wrmszNV48cpKlHom--o6A8#' was not upgraded to websocket
E/flutter (10329): #0 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1011:41)
E/flutter (10329): #1 WebSocket.connect (dart:_http/websocket.dart:320:22)
E/flutter (10329): #2 new IOWebSocketChannel.connect (package:web_socket_channel/io.dart:81:28)
E/flutter (10329): #3 connect (package:web_socket_channel/src/_connect_io.dart:15:24)
E/flutter (10329): #4 new WebSocketChannel.connect (package:web_socket_channel/src/channel.dart:144:16)
E/flutter (10329): #5 WebSocketTransport.connect (package:signalr_netcore/web_socket_transport.dart:53:35)
E/flutter (10329):
[2024-04-30 16:26:38.923305 SignalR LatLng] error: null message: Connection disconnected. message: null
[2024-04-30 16:26:38.924468 SignalR LatLng] error: null message: HubConnection.connectionClosed(null) called while in state HubConnectionState.Connecting. message: null
[2024-04-30 16:26:38.925441 SignalR LatLng] error: null message: Hub handshake failed with error 'The underlying connection was closed before the hub handshake could complete.' during start(). Stopping HubConnection. message: null
[2024-04-30 16:26:38.926642 SignalR LatLng] error: null message: Call to HttpConnection.stop(Exception: The underlying connection was closed before the hub handshake could complete.) ignored because the connection is already in the disconnected state. message: null
[2024-04-30 16:26:38.927433 SignalR LatLng] error: null message: HubConnection failed to start successfully because of error 'The underlying connection was closed before the hub handshake could complete.'. message: null
[2024-04-30 16:26:39.932434 SignalR LatLng] error: null message: Starting HubConnection. message: null
[2024-04-30 16:26:39.933370 SignalR LatLng] error: null message: Starting connection with transfer format 'TransferFormat.Text'. message: null
[2024-04-30 16:26:39.940699 SignalR LatLng] error: null message: Sending negotiation request: https://realtime.********yapp.net/hub/negotiate?negotiateVersion=1 message: null
[2024-04-30 16:26:39.942024 SignalR LatLng] error: null message: HTTP send: url 'https://realtime.********.net/hub/negotiate?negotiateVersion=1', method: 'POST' content: '' content length = '0' headers: '{ content-type: text/plain;charset=UTF-8 }, { X-Requested-With: FlutterHttpClient }, { authorization: Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImY3NTZjNmJjLTEwYTQtNGE0Ny1jM2IwLTA4ZGM1Yzc2Y2Q1OCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkRyaXZlciIsImV4cCI6MTcxNDQ5ODM2MywiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NzA4Ny8iLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MDg3LyJ9.fuxYpVypm3nzA15qMwbO9wrmszNV48cpKlHom--o6A8 }, { Authorization: Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImY3NTZjNmJjLTEwYTQtNGE0Ny1jM2IwLTA4ZGM1Yzc2Y2Q1OCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkRyaXZlciIsImV4cCI6MTcxNDQ5ODM2MywiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NzA4Ny8iLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MDg3LyJ9.fuxYpVypm3nzA15qMwbO9wrmszNV48cpKlHom--o6A8 }' message: null
[2024-04-30 16:26:40.579387 SignalR LatLng] error: null message: Selecting transport 'HttpTransportType.WebSockets'. message: null
[2024-04-30 16:26:40.580031 SignalR LatLng] error: null message: (WebSockets transport) Connecting message: null
[2024-04-30 16:26:40.585920 SignalR LatLng] error: null message: WebSocket try connecting to 'wss://realtime.****.net/hub?id=TjG-bT7yoDX30zDl2fjJmg&access_token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImY3NTZjNmJjLTEwYTQtNGE0Ny1jM2IwLTA4ZGM1Yzc2Y2Q1OCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkRyaXZlciIsImV4cCI6MTcxNDQ5ODM2MywiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NzA4Ny8iLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MDg3LyJ9.fuxYpVypm3nzA15qMwbO9wrmszNV48cpKlHom--o6A8'. message: null
[2024-04-30 16:26:40.587504 SignalR LatLng] error: null message: WebSocket connected to 'wss://realtime.****.net/hub?id=TjG-bT7yoDX30zDl2fjJmg&access_token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImY3NTZjNmJjLTEwYTQtNGE0Ny1jM2IwLTA4ZGM1Yzc2Y2Q1OCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkRyaXZlciIsImV4cCI6MTcxNDQ5ODM2MywiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NzA4Ny8iLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MDg3LyJ9.fuxYpVypm3nzA15qMwbO9wrmszNV48cpKlHom--o6A8'. message: null
[2024-04-30 16:26:40.588408 SignalR LatLng] error: null message: The HttpConnection connected successfully. message: null
[2024-04-30 16:26:40.588793 SignalR LatLng] error: null message: Sending handshake request. message: null
[2024-04-30 16:26:40.589331 SignalR LatLng] error: null message: (WebSockets transport) sending data. String data of length 32. Content: '{"protocol":"json","version":1}'. message: null
[2024-04-30 16:26:40.589708 SignalR LatLng] error: null message: Using HubProtocol 'json'. message: null
E/flutter (10329): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: WebSocketException: Connection to 'https://realtime.**********.net:0/hub?id=TjG-bT7yoDX30zDl2fjJmg&access_token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImY3NTZjNmJjLTEwYTQtNGE0Ny1jM2IwLTA4ZGM1Yzc2Y2Q1OCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkRyaXZlciIsImV4cCI6MTcxNDQ5ODM2MywiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NzA4Ny8iLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MDg3LyJ9.fuxYpVypm3nzA15qMwbO9wrmszNV48cpKlHom--o6A8#' was not upgraded to websocket
E/flutter (10329): #0 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1011:41)
E/flutter (10329): #1 WebSocket.connect (dart:_http/websocket.dart:320:22)
E/flutter (10329): #2 new IOWebSocketChannel.connect (package:web_socket_channel/io.dart:81:28)
E/flutter (10329): #3 connect (package:web_socket_channel/src/_connect_io.dart:15:24)
E/flutter (10329): #4 new WebSocketChannel.connect (package:web_socket_channel/src/channel.dart:144:16)
E/flutter (10329): #5 WebSocketTransport.connect (package:signalr_netcore/web_socket_transport.dart:53:35)
E/flutter (10329):
[2024-04-30 16:26:41.300578 SignalR LatLng] error: null message: Connection disconnected. message: null
[2024-04-30 16:26:41.301126 SignalR LatLng] error: null message: HubConnection.connectionClosed(null) called while in state HubConnectionState.Connecting. message: null
[2024-04-30 16:26:41.301848 SignalR LatLng] error: null message: Hub handshake failed with error 'The underlying connection was closed before the hub handshake could complete.' during start(). Stopping HubConnection. message: null
`
I'm using:
Exception: Unhandled Exception: WebSocketException: Connection to 'https:/xxx/hubs/main?id=5zQMxzPBiDsmCtyvURG4Gg#' was not upgraded to websocket SignalR: Failed to start with error: The underlying connection was closed before the hub handshake could complete
This is my code:
` SignalrBaseService(this._path, this._cookie) { final defaultHeaders = MessageHeaders(); defaultHeaders.setHeaderValue("Origin", origin); defaultHeaders.setHeaderValue("Cookie", 'X-AUTH-TOKEN=$_cookie');
}
Future connect() async {
try {
await _hubConnection.start();
if (isConnected) {
print('SignalR: Connected to the server: $_basePath/$_path');
}
} catch (err) {
print('SignalR: Failed to start with error: $err');
}
}
`
Cookie/origin are there for a custom cookie authorization scheme. Tracking this in debugger proves that backend authorizes correctly. But I always get this message. If i remove authorize attributes from the Hub - it will connect without issue. Also, using wscat I'm able to easily connect with/without authorize. Also, connecting to the same hub from android app, 2x angular apps.