Without having a way to model the timeouts you see, it's going to be hard to give accurate advice to fix your problems, but I can give some general advice.

* When you create your ftp object, make sure you set Debug = 1. There is also a Timeout flag you can turn on.

my $ftp = Net::FTP->new("foo.bar.com", Debug => 1, Timeout => 120);
* A lot of people here don't like the CGI101 pages but their Net::FTP page is pretty good.

* When I tested timeout code on servers that don't have an ftp server, the error I would get is: Can't call method "login" on an undefined value at ./ftp_timeout_test.pl line XX. And of course the code wouldn't continue because the module failed. But one possible work around would be something like:

* Set a timeout for, oh 300 seconds when you instantiate the Net::FTP object but then set an alarm for 295 seconds just prior to that. Trap the alarm signal to give you a timeout. If the connection proceeds smoothly, then unset the alarm.

In reply to Re: Net:FTP timeout handaling by dwm042
in thread Net:FTP timeout handaling by kian.tern

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.