IMAP disconnect broken?

Hi folks,

New Ruby 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

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

路路路

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

Hi folks,

New Ruby 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?

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Eric Hodel wrote:

Hi folks,

New Ruby 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?

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

I cannot replicate the problem with my imap4 server.

路路路

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

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 4/28/06, Stuart Stegall <stuart@footworkmedia.com> wrote:

Eric Hodel wrote:
>
> On Apr 25, 2006, at 2:21 PM, Bealach Na Bo wrote:
>
>> Hi folks,
>>
>> New Ruby 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?
>
> 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
>
I cannot replicate the problem with my imap4 server.

Did you use SSL?

I have Dovecot.

路路路

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

Eric Hodel wrote:

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

Hi folks,

New Ruby 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?

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

I cannot replicate the problem with my imap4 server.

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Eric Hodel wrote:

Eric Hodel wrote:

Hi folks,

New Ruby 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?

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

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. 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.

路路路

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

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

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 5/1/06, Stuart Stegall <stuart@footworkmedia.com> wrote:

Eric Hodel wrote:
> On Apr 28, 2006, at 2:58 PM, Stuart Stegall wrote:
>
>> Eric Hodel wrote:
>>>
>>> On Apr 25, 2006, at 2:21 PM, Bealach Na Bo wrote:
>>>
>>>> Hi folks,
>>>>
>>>> New Ruby 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?
>>>
>>> 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
>>>
>> 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. 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.

Eric Hodel wrote:

Eric Hodel wrote:

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

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?

路路路

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

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

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

[SNIP]

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?

[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

Bealach Na Bo wrote:

路路路

On 5/1/06, Stuart Stegall <stuart@footworkmedia.com> wrote:

Eric Hodel wrote:
> On Apr 28, 2006, at 2:58 PM, Stuart Stegall wrote:
>
>> Eric Hodel wrote:
>>>
>>> On Apr 25, 2006, at 2:21 PM, Bealach Na Bo wrote:
>>>
>>>> Hi folks,
>>>>
>>>> New Ruby 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?
>>>
>>> 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
>>>
>> 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. 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.

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

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]

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?

[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
$

路路路

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

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

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

路路路

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

[SNIP]

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?

[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

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com