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

Mismatching/wrong error message for connect failure #9549

Closed
edo9300 opened this issue Sep 20, 2022 · 4 comments
Closed

Mismatching/wrong error message for connect failure #9549

edo9300 opened this issue Sep 20, 2022 · 4 comments
Labels
Windows Windows-specific

Comments

@edo9300
Copy link

edo9300 commented Sep 20, 2022

I use libcurl in my application, and some times I kept getting users having issues with teh application downloading contents, in my application I log all curl errors via the recommended approach, by both passing CURLOPT_ERRORBUFFER and calling curl_easy_strerror on the return code.
Those users were getting logged as the error

Couldn't connect to server (Failed to connect to pics.ygopro.co port 2096: Winsock library not initialised)

pretty weird error to get, especially since winsock is initialized in the application and the other networking parts of the application worked fine.
By providing a build of my program where I also set CURLOPT_VERBOSE in the operation, now in stderror the actual error is printed
image
but the error description returned in the error buffer still contains the wrong message.
It also turned out that those users can't access that domain even via browser, so it might be a domain blocked by their ISP (hence the timeout).

@bagder
Copy link
Member

bagder commented Sep 20, 2022

Which libcurl version on which operating system?

@edo9300
Copy link
Author

edo9300 commented Sep 20, 2022

Which libcurl version on which operating system?

Had just realized i forgot the version and was adding it, the application is linked to a static curl 7.71.1, the operating system is windows.

@bagder
Copy link
Member

bagder commented Sep 20, 2022

It looks like it uses the wrong errno so it gets the completely wrong text in there. The code has changed a bit since 7.71.0 but the current code has the same Curl_strerror() call:

curl/lib/connect.c

Lines 1073 to 1081 in 8e5b1b6

failf(data, "Failed to connect to %s port %u after "
"%" CURL_FORMAT_TIMEDIFF_T " ms: %s",
hostname, conn->port,
Curl_timediff(now, data->progress.t_startsingle),
#ifdef ENABLE_QUIC
(conn->transport == TRNSPRT_QUIC) ?
curl_easy_strerror(result) :
#endif
Curl_strerror(error, buffer, sizeof(buffer)));

@bagder bagder added the Windows Windows-specific label Sep 21, 2022
bagder added a commit that referenced this issue Sep 21, 2022
The "Failed to connect to" message after a connection failure would
include the strerror message based on the presumed previous socket
error, but in times it seems that error number is not set when reaching
this code and therefore it would include the wrong error message.

The strerror message is now removed from here and the curl_easy_strerror
error is used instead.

Reported-by: Edoardo Lolletti
Fixes #9549
@bagder bagder changed the title Mismatching/wrong error message Mismatching/wrong error message for connect failure Sep 21, 2022
@bagder bagder closed this as completed in 6267244 Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Windows-specific
Development

Successfully merging a pull request may close this issue.

2 participants