Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception: Exception: WebSocket closed with status code: 1002 #115

Open
KhayyamA47 opened this issue Oct 11, 2024 · 0 comments
Open

Comments

@KhayyamA47
Copy link

KhayyamA47 commented Oct 11, 2024

signalr_core: ^1.1.2
http: ^1.2.0
logging: ^1.2.0

final hubConnection = HubConnectionBuilder()
.withAutomaticReconnect()
.withUrl(
"https://xyz......./chatHub",
HttpConnectionOptions(

      client: IOClient(
          HttpClient()..badCertificateCallback = (x, y, z) => true),
      accessTokenFactory: () async =>
          'my_token',
      logging: (level, message) => log(message),


    ))
.build();


Future<void> connect() async {

await hubConnection.start();
log('Connected to SignalR Hub');
hubConnection.onclose((error) {
log("Connection closed: $error");
});
String? conId = hubConnection.connectionId;
log('conId $conId');
}

void main() {
connect();

Then i get above messages:

Starting HubConnection.
Starting connection with transfer format 'TransferFormat.text'.
Sending negotiation request: https://xyz..../chatHub/negotiate.
Selecting transport 'HttpTransportType.webSockets'.
(WebSockets transport) Connecting.
WebSocket connected to wss://xyz..../chatHub?id=QIB6TRwR-hTYB8cH9SOPRQ&access_token=eyJhbGciOiJIUzIjj1NijnjcnjnjedJQZXJtaXNzaW9uIjoiQ2lpdGVuIiwiZXhwIjoxNzYwMjE2NjQ1LCJpcddddkok93772hopHJ3MiOiJGSU4iLCJhdWQiOiIxMTJNb2JpbGV9.Iwo-i_YGlchLsHybKpF3RDfcz8o5M1EDU.
The HttpConnection connected successfully.
Sending handshake request.
(WebSockets transport) sending data. String data of length '32'.
Using HubProtocol 'json'.
E/flutter (16368): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: WebSocket closed with status code: 1002 (null).
E/flutter (16368):
(WebSockets transport) socket closed.
HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) called while in state ConnectionState.connected.
Connection disconnected with error 'Exception: WebSocket closed with status code: 1002 (null).'.
HubConnection.connectionClosed(Exception: WebSocket closed with status code: 1002 (null).) called while in state HubConnectionState.connecting.
HttpConnection.stopConnection(null) called while in state ConnectionState.disconnected.
Call to HttpConnection.stopConnection(null) was ignored because the connection is already in the disconnected state.
Hub handshake failed with error 'Exception: WebSocket closed with status code: 1002 (null).' during start(). Stopping HubConnection.
Call to HttpConnection.stop(Exception: WebSocket closed with status code: 1002 (null).) ignored because the connection is already in the disconnected state.
HubConnection failed to start successfully because of error '{Exception: WebSocket closed with status code: 1002 (null)..toString()}'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant