-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Comments
Summary: The |
//cc @brianquinlan |
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;
});
} |
|
Although
SecureSocket.connect()
has set atimeout
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.So I can only add a Future's own timeout to solve it:
The text was updated successfully, but these errors were encountered: