in reply to Net::FTP Timeout

Hi Carlos,

To hopefully add a bit of clarity. I have the stein book in front me, which is a must read to say the least. The timeout is a timeout on the socket operation itself. Which means, it will attempt to create a socket to the host you specify BUT if a socket is not created in 120 seconds then the operation itself will time out and the operation will return an error.

Hopefully you are catching such an error e.g.

my $ftp = Net::FTP->new(HOST) or die "Can't connect: $@\n";

and if you want to you can get the client to retry it's connection based on that error. The other thing to think about is if you are getting these errors often you might want to grab a network sniffer to determine if your network links are being overloaded or if the server is getting overloaded with connections and is becoming slower to respond.

In either case you might want to set the clients to connect in groups by time to prevent a small scale denial of service attack on your server, I don't know how many clients you have, and from consuming all possible bandwith.

Hope this helps!,
Dave -- Saving the world one node at a time

Replies are listed 'Best First'.
Re: Re: Net::FTP Timeout
by cknowlton (Acolyte) on Dec 16, 2002 at 22:50 UTC

    Thanks for your reply. I have a question in reference to your first paragraph regarding the nature of socket creation: Is a socket created only uppon connection, or is it done continually throughout the connection?

    I ran a little test where I began a connection, and started a file transfer:

    $ftp_a = Net::FTP->new($remhostname, Timeout => 120, Debug => 1) || &error && die "Cant connect to $remhostname\n"; $ftp_a->login ($remusername,$rempassword) || &error && die "Cant login to $remhostname\n"; $ftp_a->binary (); $ftp_a->cwd ("$home\/$fpath") || warn "Cant find Directory $home/$fpath\n"; $ftp_a->get("$fname") or &error && die $ftp_a->message; $ftp_a->quit;

    After the file transfer had begun, I disconnected the network cable, and watched as the script was terminated at 120 seconds from the time I removed the cable.

    I then ran the test again with the Timeout value set to 900. Again, the script terminated at the Timeout value. If the connection was restored at any time within the timout period, the transfer would continue as normal.

    I don't have a lot of experience with network programming, but this seems to imply that the timeout is for more than just the connection. However, I still don't know specifically what.


    Best Regards,

    -Carlos

    "If at first you don't succeed, skydiving is not for you!"