-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
I did this
In my project, I need to connect to an FTP server to test connectivity. I used (void)curl_easy_setopt(self->curl, CURLOPT_CONNECT_ONLY, 1L); and also set (void)curl_easy_setopt(self->curl, CURLOPT_TIMEOUT, 10L);.
During local testing, it worked fine. However, timeout issues (*server response timeout, easy_perform result: 28) were gradually reported in the project.
After trying different libcurl versions, I found that version 7.84.0 had no such problem, while the issue occurred after upgrading to libcurl 8.17.0 in the project.
While adding debug logs in libcurl to reproduce this issue, I found that when setting TIMEOUT, Curl_pp_state_timeout calls timediff_t timeout2_ms = Curl_timeleft(data, &now, FALSE);
and then takes the smaller value between timeout_ms and timeout2_ms:
timeout_ms = CURLMIN(timeout_ms, timeout2_ms).
However, in Curl_timeleft, if CONNECT_ONLY is set, it returns 0:
if((!data->set.timeout || data->set.connect_only) && !duringconnect) {
return 0; /* no timeout in place or checked, return "no limit" */
}
After taking the minimum value, Curl_pp_state_timeout returns 0, which causes Curl_pp_statemach to return a timeout error:
if(timeout_ms <= 0) {
failf(data, "server response timeout");
return CURLE_OPERATION_TIMEDOUT; /* already too little time */
}
I expected the following
This issue can be resolved, or it should be noted that these two options cannot be used simultaneously.
curl/libcurl version
curl 8.17.0
operating system
Linux (none) 4.9.37 #1 SMP PREEMPT Tue Dec 30 16:37:52 CST 2025 armv7l GNU/Linux