-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
set_connection_timeout() unexpected results #1878
Comments
I confirm this, the connection timeout is working on android (built with jni).
|
I have encountered a similar case like this which occasionally happens on Windows 10, Android, and iOS in product apps that may be accessed via Wi-Fi, cellular networks, or both. It's not easy to reproduce in the local development environment. I'm use I suspect that creating a socket over multiple network interfaces might lead to connection timeouts being longer than we expect. In the if (getaddrinfo(node, service.c_str(), &hints, &result)) {
#if defined __linux__ && !defined __ANDROID__
res_init();
#endif
return INVALID_SOCKET;
}
for (auto rp = result; rp; rp = rp->ai_next) {
...
} I apologize for bringing up this closed issue again. I noticed the fix mentioned in this comment (7d86835) should help address the long timeout problem. However, I'm a little curious as to why even with a non-blocking socket setting there is still a chance of blocking during creation. Could you please explain the deeper reasoning behind this? Lastly, I would like to express my heartfelt gratitude once more for your incredible cross-platform http library; |
@grootgordon, the following is the code of client socket connection. Lines 3488 to 3506 in 52a18c7
The reason why it uses non-blocking mode is to simulate 'connection timeout'. You can see the details in this stackoverflow post. After My change at 7d86835 tries to quit from the results loop as soon as a timeout happens. In other words, If a timeout happens, I am not sure if this comment answers your question, but hope it helps. |
Thank you for the kind words. Such a appreciation motivates me to keep maintaining cpp-httplib! |
I verified that the connection timeout was accurate by getting the timestamp of the remote service, here is my code:
The expected timeout is 10 seconds, but the actual result does not match the expectation.
The result of running on my arm64 win11 and macOS is
The results of running on the other two amd64 win11 machines are
None of the results were as expected,I want to know what caused this.
The text was updated successfully, but these errors were encountered: