Failed to complete negotiation with the server: TimeoutException after 0:00:02.000000: Future not completed Dart

Viewed 33

I am struggiling with this error - SEVERE: 2022-08-16 16:01:01.915620: Failed to complete negotiation with the server: TimeoutException after 0:00:02.000000: Future not completed

If there any chance to prevent it? I get a big pile of data and I don't want my websocket connection to fail and I need to wait until it is all done. As I understand it is not a backend issue (or, may be, I wrong, because I have searched a lot and any solutions dosen't work for me).

My code is like that:

  Future<List> fetchAllBugStuff() async {
    Logger.root.level = Level.ALL;
    Logger.root.onRecord.listen((LogRecord rec) {
      print('${rec.level.name}: ${rec.time}: ${rec.message}');
    });

    final transportProtLogger = Logger("SignalR - transport");

    Logger? logger;

    final httpConnectionOptions = HttpConnectionOptions(
      accessTokenFactory: () => SharedPreferenceService().loginWithToken(),
      headers: defaultHeaders,
      logger: transportProtLogger,
      logMessageContent: true,
    );

    final hubConnection = HubConnectionBuilder()
        .withUrl(
          'http://10.10/home',
          options: httpConnectionOptions,
        )
        .build();
    await hubConnection.start();
    List fixation = [];
    if (hubConnection.state == HubConnectionState.Connected) {
      await hubConnection
          .invoke('GetAllBigStuff')
          .then((value) => fixation = value as List);
      
    }
    hubConnection.keepAliveIntervalInMilliseconds = 10 * 60 * 60 * 1000;
    hubConnection.onclose(({error}) {
      Logger.root.level = Level.SHOUT;
      Logger.root.onRecord.listen((LogRecord rec) {
        print('${rec.level.name}: ${rec.error}: ${rec.message}');
      });
      logger?.finer(error);
    });
    // print(fixation);
    return fixation;
  }
0 Answers
Related