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 via http://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