Forum: Ruby on Rails More on IMAP

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.
635875b58ae8bbd7f83378bceac070d1?d=identicon&s=25 Daniel Bo (kleem)
on 2009-05-04 23:58
I have been attempting to implement IMAP authentication in my
organization--- it has been nothing but a nightmare. Take this simple
function (It's quick and dirty for testing purposes... definitely a
nasty recursive call in there)

def authenticate_user(u, p)
  imap=Net::IMAP.new('imap.server.net', 993, true)
  isvalid = imap.authenticate('LOGIN', u, p)
  return isvalid
rescue Errno::ECONNRESET
  authenticate_user(u, p)
rescue
  false
ensure
  imap.disconnect
end

On any platform in a flat .rb file: works 100% of the time
On Mac OS X in a RoR instance: works 100% of the time
On Ubuntu 8.10 (x64 & i386): works, but sometimes throws the
Errno::ECONNRESET error which must be rescued
On SuSE 10.2 (i386): will not rescue Errno::ECONNRESET error

What is going on?! Why do RoR instances on Linux hate Net/IMAP when
everything functions fine within Ruby itself or within OS X. There is
clearly some kind of issue with OpenSSL, but I've tried compiling from
source and cross-compiling Ruby on top of it.

It should be noted that my OS X box is using 1.8.6 darwin version of
Ruby, whereas my Linux servers are using 1.8.7 linux versions. Should I
try downgrading Ruby?

Any suggestions would be greatly appreciated.

Here are more errors for your pleasure:

/usr/lib/ruby/1.8/openssl/buffering.rb:35:in `sysread'
/usr/lib/ruby/1.8/openssl/buffering.rb:35:in `fill_rbuff'
/usr/lib/ruby/1.8/openssl/buffering.rb:106:in `gets'
/usr/lib/ruby/1.8/net/imap.rb:992:in `get_response'
/usr/lib/ruby/1.8/net/imap.rb:930:in `receive_responses'
/usr/lib/ruby/1.8/net/imap.rb:923:in `initialize'
/usr/lib/ruby/1.8/net/imap.rb:922:in `start'
/usr/lib/ruby/1.8/net/imap.rb:922:in `initialize'
/home/me/monolith/app/controllers/user_sessions_controller.rb:17:in
`new'
/home/me/monolith/app/controllers/user_sessions_controller.rb:17:in
`authenticate_user'
/home/me/monolith/app/controllers/user_sessions_controller.rb:32:in
`create'

Thanks!
This topic is locked and can not be replied to.