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

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

Open
ingvilow opened this issue Aug 4, 2022 · 2 comments

Comments

@ingvilow
Copy link

ingvilow commented Aug 4, 2022

Hi, thanks you for such great package.

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 am wrong, I have searched a lot about this problem but any solutions dosen't work in my case).

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;
  }

Thanks you for your replying :)

@ingvilow ingvilow changed the title How to send value to the get-request with SignalR? Failed to complete negotiation with the server: TimeoutException after 0:00:02.000000: Future not completed Dart Aug 17, 2022
@waadsulaiman
Copy link

It's not an Issue. Just change requestTimeout inside HubConnectionBuilder.

@PROGrand
Copy link

Common problem is race condition, especially on flutter hotReload. Check that start is not called twice at the same time. For example, if your code is based on 'chatPageViewModel.dart' just remove openConnection from model constructor:

image

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

3 participants