Forum: Ruby still having problems with exceptions in IMAP module

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Russell F. (Guest)
on 2006-01-25 04:11
I have this method defined in a program I use for checking access to
IMAP accounts.

def tryIMAP (host, usessl, user, pass)
   retryc = false
   proto = usessl ? "IMAPS" : "IMAP"
   begin
      imap = Net::IMAP.new(host, usessl ? 993 : 143, usessl)
   rescue Net::IMAP::ByeResponseError => e
     imap.disconnect if imap
     STDERR.print "#{host} #{proto} #{e.to_s}\n";
     retryc = true
   rescue => e
     imap.disconnect if imap
     STDERR.print "#{host} #{proto} #{e.to_s}\n";
     return 'aborted'
   end while retryc
   begin
     imap.login( user, pass)
     imap.logout
     imap.disconnect
     'success'
   rescue Net::IMAP::NoResponseError
     'failure'
   end
end

As you can see I explicitly have a rescue clause for
Net::IMAP::ByeResponseError but I still get the error raised at runtime
:(

 (Net::IMAP::ByeResponseError)948:in `receive_responses': * BYE
Autologout; idle for too long
        from /usr/lib/ruby/1.8/net/imap.rb:932:in `synchronize'
        from /usr/lib/ruby/1.8/net/imap.rb:932:in `receive_responses'
        from /usr/lib/ruby/1.8/net/imap.rb:917:in `initialize'
        from /usr/lib/ruby/1.8/net/imap.rb:916:in `start'
        from /usr/lib/ruby/1.8/net/imap.rb:916:in `initialize'
        from test.rb:11:in `new'
        from test.rb:11:in `tryIMAP'
        from test.rb:149
        from test.rb:105:in `each'
        from test.rb:105
        from test.rb:94:in `each'
        from test.rb:94
        from test.rb:93:in `open'
        from test.rb:93

I am testing several thousand accounts and this error happens at random
places in the list on different runs.

Can anyone suggest where I go from here. I suspect this is a bug
somewhere in imap.rb but I can't reproduce this reliably.  Sigh...

Russell
This topic is locked and can not be replied to.