Closed KovalenkoILja closed 3 years ago
The access_token
part in your logs looks off and might be the issue. Did you modify the output of the logs to replace the actual token with <token>
?
The
access_token
part in your logs looks off and might be the issue. Did you modify the output of the logs to replace the actual token with<token>
?
Yes, i remove actual token from logs for safety.
I keep getting this error
HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) called while in state ConnectionState.connecting.
I am having the very same error, except my, I don't use access tokens, my SignalR server is open to everyone. I use .NET Core 3.1 on Windows server (for some reason on Linux server I had issues).
final hubConnection = HubConnectionBuilder().withUrl(rtcUrl, HttpConnectionOptions(logging: (level, message) => print(message))).withAutomaticReconnect().build();
Now the server does not disconnect if I start the connection and keep it sitting there, it disconnects at some point after data exchange starts. I just randomly receive the error below. I have noticed something when I set transport under connection options to HttpTransportType.longPolling
it runs, yet at some point, it still disconnects. I tried reconnecting but I am unable to do so. I figure out the approximate time to disconnect is about 2 minutes (default SignalR time to disconnect is 110 seconds). I have tried to setup
if (hubConnection.state == HubConnectionState.disconnected && hubConnection.state != HubConnectionState.connecting && hubConnection.state != HubConnectionState.disconnecting){...}
I still receive the exception that I cannot call start HubConnection failed to start successfully because of error '{type 'NoSuchMethodError' is not a subtype of type 'Exception'.toString}'.
All details are in the log below.
My Server:
I/flutter ( 9610): WebSocket connected to wss://URL?id=jOxUVuMauABfLhE4VmoOYw.
I/flutter ( 9610): (WebSockets transport) socket closed.
I/flutter ( 9610): HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) called while in state ConnectionState.connecting.
I/flutter ( 9610): Call to HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) was ignored because the connection is still in the connecting state.
E/flutter ( 9610): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: Exception: HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) was called while the connection is still in the connecting state.
[38;5;248mE/flutter ( 9610): #0 HttpConnection._stopConnection[39;49m
package:signalr_core/src/http_connection.dart
[38;5;248mE/flutter ( 9610): #1 HttpConnection._startTransport.
E/flutter ( 9610): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: Read failed E/flutter ( 9610): I/flutter ( 9610): The HttpConnection connected successfully. I/flutter ( 9610): Sending handshake request. I/flutter ( 9610): (WebSockets transport) sending data. String data of length '32'. I/flutter ( 9610): Hub handshake failed with error 'NoSuchMethodError: The getter 'sink' was called on null. I/flutter ( 9610): Receiver: null I/flutter ( 9610): Tried calling: sink' during start(). Stopping HubConnection. I/flutter ( 9610): HubConnection failed to start successfully because of error '{type 'NoSuchMethodError' is not a subtype of type 'Exception'.toString}'.
@jamiewest any ideas?
I think toString is getting called on an exception that hadn't been cast as an exception. I'm off today so I will see if i can track down the problems mentioned in the issue. Thanks all for everyone's patience on this.
@zuboje I committed a few bits earlier, could try them out and let me know the outcome?
Update your reference in pubspec.yaml
to the following:
signalr_core:
git:
url: https://github.com/jamiewest/signalr_core.git
ref: 3e8abe6e5ac1dd9dd2f18c0df91bfd9c8ba8a4af
@jamiewest it looks like the problem is resolved. I am no longer receiving an error.
Hello, I keep getting a similar error to this any help?
These are the error logs...
I/flutter (14832): Starting HubConnection.
I/flutter (14832): Starting connection with transfer format 'TransferFormat.text'.
I/flutter (14832): (WebSockets transport) Connecting.
I/flutter (14832): WebSocket connected to ws:// removed for privacy reasons
I/flutter (14832): The HttpConnection connected successfully.
I/flutter (14832): Sending handshake request.
I/flutter (14832): (WebSockets transport) socket closed.
I/flutter (14832): HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) called while in state ConnectionState.connected.
I/flutter (14832): Connection disconnected with error 'Exception: WebSocket closed with status code: 1002 (null).'.
E/flutter (14832): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Bad state: Future already completed
E/flutter (14832): #0 _AsyncCompleter.complete (dart:async/future_impl.dart:45:31)
E/flutter (14832): #1 TransportSendQueue.stop
package:signalr_core/src/http_connection.dart:655
E/flutter (14832): #2 HttpConnection._stopConnection
package:signalr_core/src/http_connection.dart:291
E/flutter (14832): #3 HttpConnection._startTransport.
anyone has fixed this. The first request in the connection is authorized using the access token in the query string, but the next request are not authorized and keep giving me 401, any help please, we are stuck
I try to open connect to server and on start get exception:
{Exception: WebSocket closed with status code: 1002 (null).
What am I doing wrong?
My code:
Logs:
LogLevel.debug: Starting HubConnection. LogLevel.debug: Starting connection with transfer format 'TransferFormat.text'. LogLevel.debug: Sending negotiation request: https://ultapps.com/ws/geo/negotiate. LogLevel.debug: Selecting transport 'HttpTransportType.webSockets'. LogLevel.trace: (WebSockets transport) Connecting. LogLevel.information: WebSocket connected to wss://ultapps.com/ws/geo?id=-q9VeFkVBznJZKVRHg-o2g&access_token=<token>. LogLevel.debug: The HttpConnection connected successfully. LogLevel.debug: Sending handshake request. LogLevel.trace: (WebSockets transport) sending data. String data of length '32'. LogLevel.information: Using HubProtocol 'json'. LogLevel.trace: (WebSockets transport) socket closed. LogLevel.debug: HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) called while in state ConnectionState.connected. LogLevel.error: Connection disconnected with error 'Exception: WebSocket closed with status code: 1002 (null).'. LogLevel.debug: HubConnection.connectionClosed(Exception: WebSocket closed with status code: 1002 (null).) called while in state HubConnectionState.disconnected. LogLevel.debug: HttpConnection.stopConnection(null) called while in state ConnectionState.disconnected. LogLevel.debug: Call to HttpConnection.stopConnection(null) was ignored because the connection is already in the disconnected state. LogLevel.debug: Hub handshake failed with error 'Exception: WebSocket closed with status code: 1002 (null).' during start(). Stopping HubConnection. LogLevel.debug: Call to HttpConnection.stop(Exception: WebSocket closed with status code: 1002 (null).) ignored because the connection is already in the disconnected state. LogLevel.debug: HubConnection failed to start successfully because of error '{Exception: WebSocket closed with status code: 1002 (null)..toString}'.