Forum: Ruby IMAP disconnect broken?

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.
3dda2c76123692d982b648851f710269?d=identicon&s=25 Bealach Na Bo (Guest)
on 2006-04-25 23:24
(Received via mailing list)
Hi folks,

New Ruby convert here :)

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
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-04-28 22:58
(Received via mailing list)
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 Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
08e4fd192c00c7136ca2ee38105213f7?d=identicon&s=25 Stuart Stegall (Guest)
on 2006-04-28 23:59
(Received via mailing list)
Eric Hodel wrote:
>> disconnect method of the imap instance it just hangs. The minimal
>       @sock.close
>     end
>
I cannot replicate the problem with my imap4 server.
3dda2c76123692d982b648851f710269?d=identicon&s=25 Bealach Na Bo (Guest)
on 2006-04-29 00:33
(Received via mailing list)
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
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-05-03 18:56
(Received via mailing list)
On Apr 28, 2006, at 2:58 PM, Stuart Stegall 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 Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
08e4fd192c00c7136ca2ee38105213f7?d=identicon&s=25 Stuart Stegall (Guest)
on 2006-05-03 18:56
(Received via mailing list)
Eric Hodel 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.
3dda2c76123692d982b648851f710269?d=identicon&s=25 Bealach Na Bo (Guest)
on 2006-05-03 18:56
(Received via mailing list)
On 5/1/06, Stuart Stegall <stuart@footworkmedia.com> 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
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-05-03 18:58
(Received via mailing list)
On Apr 30, 2006, at 3:04 PM, Stuart Stegall 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 Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
08e4fd192c00c7136ca2ee38105213f7?d=identicon&s=25 Stuart Stegall (Guest)
on 2006-05-03 18:59
(Received via mailing list)
[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
08e4fd192c00c7136ca2ee38105213f7?d=identicon&s=25 Stuart Stegall (Guest)
on 2006-05-03 18:59
(Received via mailing list)
Bealach Na Bo wrote:
>> >>>> New Ruby convert here :)
>> >>> 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.)
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-05-04 07:51
(Received via mailing list)
On May 1, 2006, at 6:02 PM, Stuart Stegall 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 Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-05-04 09:18
(Received via mailing list)
On May 1, 2006, at 6:02 PM, Stuart Stegall 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 Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
This topic is locked and can not be replied to.