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

Unreliable network connection timeout parameters #56054

Open
tilongzs opened this issue Jun 20, 2024 · 4 comments
Open

Unreliable network connection timeout parameters #56054

tilongzs opened this issue Jun 20, 2024 · 4 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io P3 A lower priority bug or feature request triaged Issue has been triaged by sub team type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@tilongzs
Copy link

Although SecureSocket.connect() has set a timeout parameter of 500ms, I just encountered a situation where the timeout exception is not thrown even after exceeding 500ms, and the reason is unknown. Although the connection timeout was caused by a server failure, SecureSocket.connect() should not be interpreted literally as not throwing timeout exceptions.

try{
await SecureSocket.connect(remoteIP, remotePort,
            timeout: Duration(milliseconds: 500), onBadCertificate: (X509Certificate){
              return true;
            });
}catch(e){
      // Timeout exceptions that may not be triggered at times
    }

So I can only add a Future's own timeout to solve it:

try{
await SecureSocket.connect(remoteIP, remotePort,
            timeout: Duration(milliseconds: 500), onBadCertificate: (X509Certificate){
              return true;
            }).timeout(Duration(milliseconds: 500));
} on TimeoutException catch (e) {
// Actual triggered timeout
}catch(e){
      // Timeout exceptions that may not be triggered at times
    }
@dart-github-bot
Copy link
Collaborator

Summary: The SecureSocket.connect() method with a specified timeout parameter does not consistently throw a timeout exception when the connection exceeds the set duration, leading to unreliable network connection timeouts. This issue requires investigation to determine why the timeout parameter is not being enforced as expected.

@dart-github-bot dart-github-bot added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jun 20, 2024
@a-siva
Copy link
Contributor

a-siva commented Jun 20, 2024

//cc @brianquinlan

@a-siva a-siva added P3 A lower priority bug or feature request triaged Issue has been triaged by sub team labels Jun 26, 2024
@brianquinlan
Copy link
Contributor

We might not apply the timeout early enough:

  static Future<_NativeSocket> connect(dynamic host, int port,
      dynamic sourceAddress, int sourcePort, Duration? timeout) {
    return startConnect(host, port, sourceAddress, sourcePort)
        .then((ConnectionTask<_NativeSocket> task) {
      Future<_NativeSocket> socketFuture = task.socket;
      if (timeout != null) {
        socketFuture = socketFuture.timeout(timeout, onTimeout: () {
          task.cancel();
          throw createError(
              null, "Connection timed out, host: ${host}, port: ${port}");
        });
      }
      return socketFuture;
    });
  }

@tilongzs
Copy link
Author

close() also encountered the same problem. Suggest conducting a unified investigation to identify potential issues with interfaces with timeouts.

@lrhn lrhn removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io P3 A lower priority bug or feature request triaged Issue has been triaged by sub team type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants