Hi Brian!

I don't know about Net::FTP, but as a suggestion: what if you spawned
a separate thread right before you open the connection and that thread
does a: sleep(30) then checks the FTP connection and forces it to
close if need be.

Of course, if there isn't a way to check the connection separately,
that may not work.

The flip-side may make more sense, while I think of it: spawn a thread
to do the FTP connection and have your main thread sleep 30 seconds.
Then have the main thread check the status and if need be kill the FTP
connection or the child thread altogether.

Just a thought. :-)

-Danimal

On Mar 31, 8:14 am, Brian Zzzzzz <rails-mailing-l...@andreas-s.net>
wrote:
> Hello,
>
> This may be more of a Ruby question but I'm using Ruby on Rails so I
> thought I would post it here.
>
> Hopefully someone can provide a suggestion on how to approach this.
>
> I have a method that uploads a selection of files via FTP. For each file
> the method gets the file's associated ftp host/domain, user name and
> password, connects, uploads the file, updates the status of the file and
> saves the updated information.
>
> I'm now setting up error handling to email the file owner if the
> response_code is not the expected successful code.
>
> If a file has incorrect ftp information associated with it, I want to
> send an email to the file owner to notify them, shouldn't be a problem.
>
> So, if there is incorrect connection info, Net::FTP will retry
> connecting until it times out which could be 3 to 5 minutes or more
> depending on the FTP server's configuration.
>
> I want to keep track of elapsed time and if the connection is not
> established within 30 seconds, I want to cancel the connection and send
> an email about the error to the file owner and move on to the next file.
>
> So basically I want to make my own timeout, which times out faster than
> the external FTP server.
>
> [code]
>  start_timer_if_elapsed_time>=_30_seconds_cancel_connection
>  #open ftp connection
>  Net::FTP.open(ftp_link, ftp_username, ftp_password) # <-- this line
> shouldn't attempt to connect longer than 30 seconds
>
>  do |ftp|
>
>    ## send the file to the ftp
>    ## update the status
>    ## save the file
>  end
> [/code]
>
> Any suggestions appreciated
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to