Welcome Guest | Login

Timeout Error Net::POP3

Hey, Im trying to run a daemon (using daemons gem) to check for email and then write to the console for every email in my inbox. The problem, is that I keep receiving timeout::error.

Heres my code

email.rb
require "net/pop"

loop do
 Net::POP3.start('mail.mylittlesecret.co.uk', 110,
                     'test+mylittlesecret.co.uk', 'somepassword') do |pop|
       if pop.mails.empty?
           puts 'No mail.'
       else
           pop.each_mail do |m|
             puts "mail"
           end
       end
     end
 
 sleep(10)
end
email_control.rb
require 'rubygems'
require 'daemons'

Daemons.run('email.rb')
(Im trying to run this in development, on rails 2.0 and ruby 1.8.6)

Thanks, Red

2008-01-04 06:44 AM

Hello,

Net::POP3 is up to date on the server with version(2.29). Also can you post the exact error logs that you are obtaining at your end.

Since you are mentioning a "time-out" issue, Can you check if the port 110 is blocked at your local end or not. You can either netstat (linux) or telnet (windows or linux) commands to check it out.

2008-01-04 07:08 AM

Regards,
Rahul
Hey thanks for replying

Here is my error
/usr/local/lib/ruby/1.8/timeout.rb:54:in `new': execution expired (Timeout::Error)
from /usr/local/lib/ruby/1.8/net/protocol.rb:206:in `old_open'
from /usr/local/lib/ruby/1.8/timeout.rb:56:in `timeout'
from /usr/local/lib/ruby/1.8/timeout.rb:76:in `timeout'
from /usr/local/lib/ruby/1.8/net/protocol.rb:206:in `old_open'
from /usr/local/lib/ruby/1.8/net/pop.rb:438:in `do_start'
from /usr/local/lib/ruby/1.8/net/pop.rb:426:in `start'
from /usr/local/lib/ruby/1.8/net/pop.rb:329:in `start'
from /Users/reddavis/Documents/projects/account/accounts/lib/tasks/email.rb:4
 ... 7 levels...
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons/cmdline.rb:105:in `call'
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons/cmdline.rb:105:in `catch_exceptions'
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons.rb:135:in `run'
from email_control.rb:4
And here is my telnet result

reddavis$ telnet mylittlesecret.co.uk 110
Trying 74.86.164.232...
Connected to mylittlesecret.co.uk.
Escape character is '^]'.
+OK Hello there.
Thanks, Red

2008-01-04 07:24 AM

Hello,

Can you have a look into the following link.
http://www.ruby-doc.org/stdlib/libdoc/net/pop/rdoc/classes/Net/POP3.html

Maybe a few tweaking of the codes will help. Also there is no problems with the pop service on  the server. So the codes responsible for establishing connection with the server is failing.
Do let us know if this doesn't help you out.

2008-01-04 07:55 AM

Regards,
Rahul
Hey

I've played around with the code a bit more and still nothing. I had this problem at the start of the project so decided to come back to it.

Heres my new code
require "net/pop"

loop do
 
     pop = Net::POP3.new('mail.mylittlesecret.co.uk')
     pop.start('test+mylittlesecret.co.uk', 'something')            
     if pop.mails.empty?
       puts 'No mail.'
     else
         pop.each_mail do |m|  
           puts "mail Here"
         end
     end
     pop.finish
     
 sleep(10)
 
end
Error
/usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons/application.rb:159:in `load': /Users/reddavis/Documents/projects/account/accounts/lib/tasks/email.rb:19: syntax error, unexpected kEND, expecting $end (SyntaxError)
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons/application.rb:159:in `start_load'
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons/application.rb:236:in `start'
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons/controller.rb:72:in `run'
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons.rb:136:in `run'
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons/cmdline.rb:105:in `call'
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons/cmdline.rb:105:in `catch_exceptions'
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons.rb:135:in `run'
from email_control.rb:4
jim:tasks reddavis$ ruby email_control.rb run
/usr/local/lib/ruby/1.8/timeout.rb:54:in `new': execution expired (Timeout::Error)
from /usr/local/lib/ruby/1.8/net/protocol.rb:206:in `old_open'
from /usr/local/lib/ruby/1.8/timeout.rb:56:in `timeout'
from /usr/local/lib/ruby/1.8/timeout.rb:76:in `timeout'
from /usr/local/lib/ruby/1.8/net/protocol.rb:206:in `old_open'
from /usr/local/lib/ruby/1.8/net/pop.rb:438:in `do_start'
from /usr/local/lib/ruby/1.8/net/pop.rb:432:in `start'
from /Users/reddavis/Documents/projects/account/accounts/lib/tasks/email.rb:6
from /Users/reddavis/Documents/projects/account/accounts/lib/tasks/email.rb:3:in `loop'
 ... 6 levels...
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons/cmdline.rb:105:in `call'
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons/cmdline.rb:105:in `catch_exceptions'
from /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.9/lib/daemons.rb:135:in `run'
from email_control.rb:4

jim:tasks reddavis$
It takes roughly 70seconds for the telnet to connect, could this time length cause a timeout? If so is there a way I can change the timeout length?

Thanks for your help

Red

2008-01-04 11:28 AM

You could try changing the timeout at

/usr/local/lib/ruby/1.8/timeout.rb:56:in `timeout'

but that shouldn't be it.  There must be something preventing the protocol connection (per the discussion above)

Also, check the "email.rb:19: syntax error, unexpected kEND, expecting $end (SyntaxError)"

2008-01-05 02:20 AM

Hey

Thanks for everyones help.

I fixed the problem by replacing mail.mylittlesecret.co.uk, with the ip

Thanks, Red

2008-01-05 04:43 AM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!