curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder Daniel himself.

When using ActiveMode of FTPS on Curl for Windows, it takes polling timeout time (1000msec) to establish DataConnection.

From: Yoshimasa Ohno via curl-library <curl-library_at_lists.haxx.se>
Date: Sat, 31 Aug 2024 08:59:37 +0900

Hello everyone.

When using FTPS Acitive mode in the Windows version of Curl environment,
DataConnection establishment takes a timeout period.
Does anyone know of a solution?

---- Condition begin ----
Client-side:
 Protocol: FTPS (explicit or implicit)
 Curl Version(module): curl-8.9.1 (curl-8.9.1_3-win64-mingw)
 OS: Windows 10 Version 22H2 (OS Build 19045.4780)

Server-side:
 FTP server: Filezilla server 1.8.2
 Network: Addjacent network (local network or local host)

Command:
 curl --ssl-reqd --tls-max 1.2 -k --user Anonymous: ftp://localhost:21/ -P
-
---- Condition end ----

Looking at the packet, after the TCP socket SYN/ACK, there is exactly one
second of wait before the Client Hello is sent.

I built and investigated independently from source.

The following WSAWaitForMultipleEvents is causing a 1 second wait.
https://github.com/curl/curl/blob/83bedbd730d62b83744cc26fa0433d3f6e2e4cd6/lib/multi.c#L1438
    else { /* now wait... if not ready during the pre-check (pollrc == 0) */
      WSAWaitForMultipleEvents(1, &multi->wsa_event, FALSE,
(DWORD)timeout_ms,
                               FALSE);
    }

I found that the timeout argument of curl_multi_poll, the literal 1000, was
having an effect.
Changing this to 3000 resulted in a 3 second wait.
https://github.com/curl/curl/blob/83bedbd730d62b83744cc26fa0433d3f6e2e4cd6/lib/easy.c#L673
    mcode = curl_multi_poll(multi, NULL, 0, 1000, NULL);

Adding a 1 ms sleep at the beginning of static CURLcode
ReceivedServerConnect (struct Curl_easy *data, bool *received) would have
avoided the delay problem.
https://github.com/curl/curl/blob/83bedbd730d62b83744cc26fa0433d3f6e2e4cd6/lib/ftp.c#L533C1-L533C78


As additional information, the problem did not occur in Plain FTP or PASV
mode or when the server side was Microsoft IIS.
Also, the problem did not occur when the Verbose command was turned on (I
think it had the same effect as Sleep).
(I think it had the same effect as Sleep).

I am having trouble determining if it is a client-side or server-side
problem.
Any information at all would be appreciated.

Thanks.


-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2024-08-31