Subject: | passive ftp upload stor command sent before dataconnection is open |
Hi,
I encountered a problem when uploading files. I was getting "550 access is denied" sometimes for no reason, and most of the time when the server (or the connection) was busy.
It turns out that the net::ftp module first sends the STOR command, and then opens the dataconnection. If too much time passes between those two events (or if i insert a 1 second sleep command ), then the server doesn't know what data to put in the file opened by the stor command, and returns a 550 error.
I looked at the FTP RFC and i don't find it very clear what the correct order of events is, but elsewhere on the web, it seems that the dataconnection should be open first before the STOR command is sent. In any case, it works for me if change it that way.
In the code i made the following change:
in Net/FTP.pm, line 1043-1044, i changed
$ftp->command($cmd,@_);
$data = $ftp->_dataconn();
into
$data = $ftp->_dataconn();
$ftp->command($cmd,@_);
voila.
This solved the problem for me, but I think it only solves the problem in passive ftp mode, which is what i use. I don't know about active mode though or uploads or any of the other possible cases, Someone who knows more than me about the ftp protocol and the Net::FTP module should probably take a look at it ;)
regards,
Tom Brusselle