Net::FTP and Passive mode problems

H

Hostile17

I'm using Net::FTP to upload a file.

The server to which I'm uploading requires that I do so in Passive
mode.

I start Net::FTP with "Passive => 1", but the upload takes just over
two minutes, for a tiny file.

Except, it probably isn't really taking two minutes, it's trying to
transfer _non_ passively, then switching modes.

The debug info looks like this:

230 User foobar logged in.
CWD /path/to/files/
250 CWD command successful.
ALLO 5
Timeout at ftpscript.pl line 23 ### SEE BELOW
PASV
227 Entering passive mode (123,4,56,78,910,123)
STOR foobar.txt
125 Data connection already open; Transfer starting.
226 Transfer complete.

Line 23 is where the script says to $ftp->put() my file.

So why, when I've told it to use Passive, is it waiting for a timeout
and only _then_ issuing the PASV message?

TIA
 
A

A. Sinan Unur

(e-mail address removed) (Hostile17) wrote in
I'm using Net::FTP to upload a file.

The server to which I'm uploading requires that I do so in Passive
mode.

I start Net::FTP with "Passive => 1", but the upload takes just over
two minutes, for a tiny file.

Where is the code you are actually using? Please provide the shortest
possible program that still exhibits the problem you are experiencing.
Except, it probably isn't really taking two minutes, it's trying to
transfer _non_ passively, then switching modes.

The debug info looks like this:

230 User foobar logged in.
CWD /path/to/files/
250 CWD command successful.
ALLO 5
Timeout at ftpscript.pl line 23 ### SEE BELOW
PASV
227 Entering passive mode (123,4,56,78,910,123)
STOR foobar.txt
125 Data connection already open; Transfer starting.
226 Transfer complete.

Line 23 is where the script says to $ftp->put() my file.

Then the error is on line 42.
So why, when I've told it to use Passive, is it waiting for a timeout
and only _then_ issuing the PASV message?

Well, you tell us. After all, you are the one looking at the code.

Sinan.
 
H

Hostile17

A. Sinan Unur said:
(e-mail address removed) (Hostile17) wrote in
news:[email protected]:
Where is the code you are actually using? Please provide the shortest
possible program that still exhibits the problem you are experiencing.

I didn't post it because there's almost nothing to tell. And I posted
the Debug info -- but here you go anyway:

use Net::FTP;
$ftp = Net::FTP->new(
"server.name.com",
Passive => 1,
);
$ftp->login( 'username', 'password' );
$ftp->cwd("/path/to/desired/folder/");
$ftp->put( "adsf.txt", 'adsf.txt' ); ## 2-Minute wait on this line

Debug output:
Then the error is on line 42.

That's an old joke for complete newbies, and I'm really not a
_complete_ newbie.

When my script gets to line 23, it waits for two minutes, then issues
the PASV message. That's why I turned on Debug and posted the output
here.

Unless you come and sit in my office, you're just going to have to
believe me about the two minutes.

My question is, when I told the module to use the Passive mode, why
does it wait two minutes, time out, and then switch to Passive mode?

After it's done that, the transfer happens in less than a second.

Does Passive => 1, for instance, really mean "don't go into Passive
mode straight away, wait for <timeout value> seconds and then do it?"
and if so, shouldn't the doco say "if you use this, set Timeout to one
second"? I just checked, and it doesn't.
 
A

A. Sinan Unur

(e-mail address removed) (Hostile17) wrote in
I didn't post it because there's almost nothing to tell. And I posted
the Debug info -- but here you go anyway:

Why don't you have:

use strict;
use warnings;

use Net::FTP;
$ftp = Net::FTP->new(
"server.name.com",
Passive => 1,
);
$ftp->login( 'username', 'password' );
$ftp->cwd("/path/to/desired/folder/");
$ftp->put( "adsf.txt", 'adsf.txt' ); ## 2-Minute wait on this line

Debug output:

....

When my script gets to line 23, it waits for two minutes, then issues
the PASV message. That's why I turned on Debug and posted the output
here.
....

My question is, when I told the module to use the Passive mode, why
does it wait two minutes, time out, and then switch to Passive mode?

I don't know.

However, the Net::FTP docs do mention that you should normally not need to
set this parameter.

On the other hand, did you try:

#! perl

use strict;
use warnings;

use Net::FTP;

my $ftp = Net::FTP->new('host.invalid', Debug => 1);
$ftp->login( 'user', 'pass' ) or die 'login failure';
$ftp->cwd('public_ftp') or die 'cannot cwd';
$ftp->pasv or die 'cannot set pasv mode';
$ftp->put('test.txt') or die 'transfer failure';
$ftp->quit;
__END__
 
H

Hostile17

A. Sinan Unur said:
Why don't you have:

use strict;
use warnings;

Because you asked for the "shortest possible script".
I don't know.

However, the Net::FTP docs do mention that you should normally not need to
set this parameter.

I'll refer our system administrator to that document right away. I'm
sure they'll change the way the server is set up in shame.
On the other hand, did you try:

[SNIP]

I just tried it. The transfer took two minutes, just the same as
before.

I don't mean to be rude, but you're not helping. The two of us are
wasting time on a conversation which can be reduced to:

ME: Why does NET::FTP do this?
YOU: Don't know.

And it's actually a purely theoretical question at this stage, as I've
already figured out a workaround. I was hoping to _learn_ something...

Anyone else?
 
A

A. Sinan Unur

(e-mail address removed) (Hostile17) wrote in
Because you asked for the "shortest possible script".

That does not mean "post an incomplete script".
I don't mean to be rude, but you're not helping. The two of us are
wasting time on a conversation which can be reduced to:

ME: Why does NET::FTP do this?
YOU: Don't know.

I gave you a script that "worked" as expected on Win98, WinXP and
FreeBSD. You may not have realized it, but before posting it, I actually
tested it from behind a firewall with 2 servers. So, since you did not
post a complete script, and since I had no way of knowing what was
happening on your particular system (you did not post a complete log
either), I asked you to see if something I _knew_ worked properly still
exhibited the problem.

At this stage, my feeling is that your problem is just that: Your
problem.

Enjoy.
 
S

Sherm Pendley

Hostile17 said:
So why, when I've told it to use Passive, is it waiting for a timeout
and only _then_ issuing the PASV message?

The Net::FTP docs mention that it's also influenced by a FTP_PASSIVE
environment variable. Does the script behave differently when you use
this instead of the method parameter?

sherm--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top