Skip to content

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

@KhayyamA47

Description

@KhayyamA47

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()}'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions