Hi all,
I have a question relating to Net::FTP. I'm working on a system that will compress and upload very large video files over potentially unreliable connections.
The first part uses FFmpeg to compress the video into something manageable and the second part uses Net::FTP to transfer the file. It needs to be able to be run unattended for a long period of time, and hence to try to recover gracefully from any errors.
I use this loop to upload:
do {
$ftp->restart($transferred);
++$attempts;
if($attempts>2){
mesg('*',"Having trouble writing to server, on attempt $at
+tempts...",$evqueue);
}
$written=$dataconn->write($buffer,$to_transfer,$config->{'time
+out'});
if($attempts>$soft_retries){
mesg('*',"Connection appears to be dead. Attempting to re
+-start...",$evqueue);
$ftp=undef;
$ftp=ftp_transfer::connect($config,$evqueue) while(not def
+ined $ftp);
$ftp->binary;
$ftp->restart($transferred);
}
} while($written<$to_transfer);
$transferred+=$written;
having first got
$dataconn from a $ftp->stor().
This works for upload, but when I tested it out by dropping the wireless connection while the upload was in progress it would not resume - it simply said "thread failed to start, timeout at ftp_transfer.pm line 35"
Do I need to somehow subclass dataconn in order to be able to pick up after a timeout?
Your help is much appreciated...
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.