I am experiencing an intermittent problem with a module written to wrap Net::FTP.
The symptoms are that the two machines (between which the ftp connection
is established) perform various suceessful TCP hand-shakes. But when it
comes to 'put' the file, one machine no longer has the TCP ftp data
transfer port connection. The whole process then hangs as one machine
waits for the other to supply it data that the other machine doesn't
think exists.
The problem does not occur regularly. The files are small. The OS vary
(Unix->Linux). All module versions have been checked. And so forth.
Here is a slightly edited version of the module:
package MyWrapper::FTP;
use vars qw( @ISA );
@ISA = qw( MyWrapper );
require Net::FTP;
use strict;
my $FTP_TIMEOUT = 60;
sub create_connection
{
my ($self, $connection_string) = @_;
$connection_string =~ /^(\w+):(\S+)@(\S+)$/;
my ($login,$password,$host) = ($1,$2,$3);
my $ftp;
eval
{
$login && $password && $host
or die "Can't parse connection string '".$self->connection
+_string."'\n";
$ftp = new Net::FTP($host, (Timeout=>$FTP_TIMEOUT) );
die "FTP: failed to connect to $host: $!\n" if not $ftp;
$ftp->login($login, $password)
or die "FTP: Can not login to $login\@$host\n";
$ftp->binary;
};
if ($@)
{
# Do some logging.
}
$self->set('host', $host);
return $ftp;
}
sub send_file
{
my ($self, $file, $outfile) = @_;
my $host = $self->get('host');
my $ftp = $self->ftp;
my $workfile;
$workfile = 'test.tst'; # Various unrelated decisions
# on what $workfile is occur here.
if( $ftp->put($file, $workfile) )# <--- This is where it apparentl
+y hangs.
{
# Log some intermediary success.
if( $ftp->rename($workfile,$outfile) )
{
# Log some success.
}
else
{
die( "FTP: $file -> $host:$outfile - FAILED: $!\n" );
}
}
else
{
die( "FTP: $file -> $host:$outfile - FAILED: $!\n" );
}
}
1;
- Graq
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.