IMAP disconnect broken?

Hi folks,

New R. convert here :slight_smile:

I’m using the standard Net::IMAP and OpenSSL libraries to connect to
an IMAP server.
I can connect, examine and manipulate my INBOX, but when call the
disconnect method of the imap instance it just hangs. The minimal
version is almost identical to
the example on page 701 of “Programming Ruby”. Should I be calling
some other method?

require ‘net/imap’
require ‘openssl’
server, login, password = ‘imap.server’,‘my_login’,‘my_password’
imap = Net::IMAP::new(server, 993, true)
imap.login(login,password)
imap.examine(‘INBOX’)
puts “Message count: #{ imap.responses[“EXISTS”]}”
imap.search([“To”, “Me”]).each do |message_id|
envelope = imap.fetch(message_id, “ENVELOPE”)[0].attr[“ENVELOPE”]
puts “#{envelope.from[0].name}: \t#{envelope.subject}”
end
imap.disconnect

Regards,

Bealach

On Apr 25, 2006, at 2:21 PM, Bealach Na Bo wrote:

some other method?
I don’t know, the disconnect method is suspect:

 # Disconnects from the server.
 def disconnect
   @sock.shutdown unless @usessl
   @receiver_thread.join
   @sock.close
 end


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Eric H. wrote:

disconnect method of the imap instance it just hangs. The minimal
@sock.close
end

I cannot replicate the problem with my imap4 server.

I’ve not set up my own IMAP server to test this, but I just might.
Sadly, that will not solve the problem for since I do not have admin
access to the IMAP server I’m experiencing problems with
(incidentally, that too is an IMAP 4 server).

Bealach

On Apr 28, 2006, at 2:58 PM, Stuart S. wrote:

I can connect, examine and manipulate my INBOX, but when call the
@receiver_thread.join
@sock.close
end

I cannot replicate the problem with my imap4 server.

Did you use SSL?

I have Dovecot.


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

On 5/1/06, Stuart S. [email protected] wrote:

# Disconnects from the server.

I have Dovecot.

Is your code anything like what I posted (quoting from “Programming
Ruby”)? I’ve tried that code in Debian, WinXP pro (SP2) and Win2003
all with ruby 1.8.4 and all of them hang at exactly the same place.
Can you post some example code if it’s different to what I posted.

Regards,

Bealach

On Apr 30, 2006, at 3:04 PM, Stuart S. wrote:

  @receiver_thread.join
  @sock.close
end

I cannot replicate the problem with my imap4 server.

Did you use SSL?

I have Dovecot.

I used SSL and I tried it on Gentoo Linux and Windows. […]

This problem has nothing to do with SSL on the client side.

But I digress, on both platforms, I got the exact same lack of a
problem.

What mail server are you using?


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Eric H. wrote:

I’m using the standard Net::IMAP and OpenSSL libraries to connect to
def disconnect

I used SSL and I tried it on Gentoo Linux and Windows. The Windows is
all my own compiling as I am using the Intel C++ compiler to compile
everything (which of course causes me problems with some
gems/addons/libraries as they are precompiled for Windows and do not
include nmake makefile or VS project files and then I have to TRY to
manually make a makefile for them)

But I digress, on both platforms, I got the exact same lack of a
problem.

Bealach Na Bo wrote:

New R. convert here :slight_smile:
I don’t know, the disconnect method is suspect:
Did you use SSL?
But I digress, on both platforms, I got the exact same lack of a
Bealach

I used the same code, but did you use the same IMAP server for all of
your tests? (I did for mine, but of course it worked for me.)

[SNIP]

[SNIP
I am not sure what server it is. I teleneted to port 143 and 993 (I
have a special perl SSL telnet program for testing SSL ports) and It
just says IMAP4rev1

On May 1, 2006, at 6:02 PM, Stuart S. wrote:

[SNIP
I am not sure what server it is.

Could you find out? It’ll help track down where the bug really is.

I teleneted to port 143 and 993 (I have a special perl SSL telnet
program for testing SSL ports) and It just says IMAP4rev1

dovecot says:

$ openssl s_client -connect mail.robotcoop.com:imaps
CONNECTED(00000004)
[openssl output]

  • OK Dovecot ready.
    QUIT
    DONE
    $


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

On May 1, 2006, at 6:02 PM, Stuart S. wrote:

[SNIP
I am not sure what server it is. I teleneted to port 143 and 993
(I have a special perl SSL telnet program for testing SSL ports)
and It just says IMAP4rev1

UW IMAP has the same problem (host name removed, not my mail server).

$ openssl s_client -connect mail.example.com:imaps
CONNECTED(00000004)

  • OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS AUTH=CRAM-MD5 AUTH=PLAIN
    AUTH=LOGIN] [w.x.y.z] IMAP4rev1 2002.332 at Wed, 3 May 2006 22:50:04
    -0700 (PDT)
    QUIT
    DONE
    $ ruby -ropenssl -rnet/imap -e ‘Net::IMAP.new(“mail.example.com”,
    993, true).disconnect’
    ^C/usr/local/lib/ruby/1.8/net/imap.rb:288:in join': Interrupt from /usr/local/lib/ruby/1.8/net/imap.rb:288:in disconnect’
    from -e:1


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com