cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: EPSV vs PASV

From: Michael Wood <esiotrot_at_gmail.com>
Date: Thu, 20 Jan 2011 09:10:14 +0200

Hi

On 20 January 2011 05:37, Leo <leo.r_at_rogers.com> wrote:
[...]
> OK, here's an example of one such FTP server. curl can't connect without
> disabling EPSV: it waits for over a minute then fails. Cyberduck connects
> without problems, and so does curl with EPSV disabled.
>
> I'm on Mac OS X 10.5.8 with libcurl 7.16.3

That is a very old version of libcurl. I suggest you upgrade it
before trying anything else.

[...]
> 2. libcurl fails with EPSV
> --------------------
>
> * About to connect() to ftp.postmedia.com port 21 (#0)
> *   Trying 204.187.151.151... connected
> * Connected to ftp.postmedia.com (204.187.151.151) port 21 (#0)
> < 220 Canwest File Transfer Server
>> USER calgaryadupload
> < 331 Password required for calgaryadupload.
>> PASS <********>
> < 230 Login OK. Proceed.
>> PWD
> < 257 "/" is current folder.
> * Entry path is '/'
>> EPSV
> * Connect data stream passively
> < 229 Entering Extended Passive Mode (|||4212|)
>
> <some 75 sec wait here>
>
> *   Trying 204.187.151.151... Operation timed out
> * couldn't connect to host
> * got positive EPSV response, but can't connect. Disabling EPSV
>> PASV

This looks like some sort of firewall/NAT issue rather than anything
libcurl can do anything about. There is no way for libcurl to know
that the network between the client and the server is broken. Clearly
the server doesn't know either or it would not have replied with "229
Entering Extended Passive Mode (|||4212|)".

> < 425 Data connection already open.

OK, so the server thinks there's nothing wrong with EPSV, but libcurl
couldn't connect, so when libcurl retried with PASV, the server says
"Hey! What are you doing? You already asked me to open a port for
EPSV and now you want me to open another one for PASV???"

I think the only way libcurl can deal with this is to close the
control channel after the EPSV failed and then open a new one when
trying the PASV. Unless maybe an ABOR command would work. But, first
try the latest version of libcurl, because it might already do
something like this. I have not checked.

> * Bad PASV/EPSV response: 425
> * Remembering we are in dir ""
> * Connection #0 to host ftp.postmedia.com left intact
> curl: (13) Bad PASV/EPSV response: 425
>> QUIT
> < 221 Service closing control connection.
> * Closing connection #0

-- 
Michael Wood <esiotrot_at_gmail.com>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-01-20