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.
Bealach Na Bo (Guest)
on 2006-04-26 01:24
(Received via mailing list)
Hi folks,

New R. 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
Eric H. (Guest)
on 2006-04-29 00: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 H. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Stuart S. (Guest)
on 2006-04-29 01:59
(Received via mailing list)
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.
Bealach Na Bo (Guest)
on 2006-04-29 02: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
Eric H. (Guest)
on 2006-05-03 20:56
(Received via mailing list)
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. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Stuart S. (Guest)
on 2006-05-03 20:56
(Received via mailing list)
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 (Guest)
on 2006-05-03 20:56
(Received via mailing list)
On 5/1/06, Stuart S. <removed_email_address@domain.invalid> 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
Eric H. (Guest)
on 2006-05-03 20:58
(Received via mailing list)
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. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Stuart S. (Guest)
on 2006-05-03 20: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
Stuart S. (Guest)
on 2006-05-03 20:59
(Received via mailing list)
Bealach Na Bo wrote:
>> >>>> New R. 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.)
Eric H. (Guest)
on 2006-05-04 09:51
(Received via mailing list)
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. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Eric H. (Guest)
on 2006-05-04 11:18
(Received via mailing list)
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. - removed_email_address@domain.invalid - 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.