Flutter WebSocket closed with status code: 1002 (null)

Viewed 218

In the application I wrote with Flutter, I was told that I need to send a tenant-id before connecting auth with SignalR and listening to the data, but I am getting the following error.

static StartSocket() async {

    HubConnection hubConnection;
    final serverUrl = "https://*****.******.org/******/";

    hubConnection = HubConnectionBuilder().withUrl(serverUrl,
        HttpConnectionOptions(
          accessTokenFactory: () async =>
          MySharedPreferences.token,
          skipNegotiation: true,
          transport: HttpTransportType.webSockets,
          client: IOClient(
              HttpClient()..badCertificateCallback = (x, y, z) => true),
          logging: (level, message) => print(message),

        )).build();


    await hubConnection.start();
    hubConnection.invoke("Register",args: [MySharedPreferences.Envisesne_Tenant]);
     hubConnection.on('sendSwitchRecord', (data) { print(data.toString());});


    hubConnection.onclose((error) {
      print("Connection Closed");
      StartSocket();
    });
}

Error

0 Answers
Related