jadolg / webpymail

Automatically exported from code.google.com/p/webpymail
GNU General Public License v3.0
0 stars 0 forks source link

SSL socket problems with EOL response from server #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
`IMAP4_SSL.readline()` does not process EOL and creates HUGE array `line` and 
then raise Memory exception.
You can prevent this by checking `self.sslobj.read(1)` length (it is == 0 if 
there EOL) or there is another solution:
IMAP4_SSL could use `wrap_socket()` from `ssl` module -- it returns `SSLSocket` 
 with all `socket` methods. So `IMAP4_SSL` class would require reimplementation 
only `open()` and `ssl()` methods. For earlier versions of python (2.3, 2.4, 
2.5) you can add http://pypi.python.org/pypi/ssl/ lib in dependency list.

Original issue reported on code.google.com by akimov.alex on 13 Aug 2010 at 3:28

GoogleCodeExporter commented 9 years ago
I'll look into this problem.

Original comment by hguerreiro@gmail.com on 19 Aug 2010 at 8:36

GoogleCodeExporter commented 9 years ago
One more suggestion: there is multyversional solution in Piers Lauder imaplib2 
v2.17 http://janeelix.com/piers/python/imaplib2_pp.html (as I've understood, 
you know about this lib ).

        try:
                import ssl
                self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile)
        except ImportError:
                self.sslobj = socket.ssl(self.sock, self.keyfile, self.certfile)

        self.read_fd = self.sock.fileno()

Original comment by akimov.alex on 19 Aug 2010 at 8:50

GoogleCodeExporter commented 9 years ago
Yap, I know that lib, Piers Lauder is the author of python's standard library, 
imapll.py and imapp.py is a ripoff of his work! ;-) (with a few customizations)

Original comment by hguerreiro@gmail.com on 19 Aug 2010 at 9:09

GoogleCodeExporter commented 9 years ago
You can test it on

mail.rambler.ru
993
ssl

webpymail:qweasdzxc

just try to refresh list_messages or list_folders views for a few times. They 
have slowly IMAP4 server with some strange behavior. At least it'll help to 
find out some 500 errors (end replace them with something a bit pretty :) )

Original comment by akimov.alex on 26 Aug 2010 at 12:14

GoogleCodeExporter commented 9 years ago
No folders on that account!

Original comment by hguerreiro@gmail.com on 26 Aug 2010 at 10:56

GoogleCodeExporter commented 9 years ago
Try now. They have fantastic IMAP server -- it's so unpredictable, e.g. folders 
appears after 3-5 connects to IMAP... I don't know why :)

Original comment by akimov.alex on 27 Aug 2010 at 6:52

GoogleCodeExporter commented 9 years ago
About the no folders error, take a look at bug 14 

I still can't reproduce this error. What operating system and python version 
are you using?

Please confirm that you've received my mail, if not drop me a note (my mail is 
on the mail page).

Original comment by hguerreiro@gmail.com on 28 Aug 2010 at 2:30

GoogleCodeExporter commented 9 years ago
I've got your mail, thank you. I've just have no time to read it for now.

About the bug: I use python 2.6, Linux (Ubuntu 10.04). I'll try to reproduce 
and send you traceback in the evening.

Original comment by akimov.alex on 29 Aug 2010 at 7:15

GoogleCodeExporter commented 9 years ago
Here is simple log.
// I quoted login and password.

S: * OK IMAP4 ready<cr><lf>
C: JLAL000 LOGIN ******** "*********"<cr><lf>
S: JLAL000 NO [SYS/TEMP] Server overloaded, try later<cr><lf>
Don't know how to handle optional code:
[SYS/TEMP] Server overloaded, try later
C: JLAL001 LOGOUT<cr><lf>
Exception MemoryError: MemoryError() in <bound method ImapServer.__del__ of 
<hlimap.imapserver.ImapServer object at 0xa72240c>> ignored
[01/Sep/2010 08:05:26] "GET /mail/FOLDER_SU5CT1g=/ HTTP/1.1" 404 1690

between LOGOUT and server response it was about 1 minute.

I've reproduced it after continuously refreshing folder list for 7-8 times for 
Rambler host.

Original comment by akimov.alex on 1 Sep 2010 at 8:14

GoogleCodeExporter commented 9 years ago
Could not reproduce the error (I'm in Debian stable with python 2.5.2 but I 
don't think this is the problem). The import trick, as is, will not improve the 
situation, IMHO, I'll use it  because socket.ssl() is deprecated in python 2.6 
anyway. Maybe you're right about the EOL detection (very odd). 

I've committed both changes in r55, could you test it now? 

Original comment by hguerreiro@gmail.com on 1 Sep 2010 at 10:05

GoogleCodeExporter commented 9 years ago
Well, I could not reproduce it too. I think you can close ticket.

Original comment by akimov.alex on 13 Sep 2010 at 8:35

GoogleCodeExporter commented 9 years ago
OK, I'm closing it for now. Thank you!

Original comment by hguerreiro@gmail.com on 13 Sep 2010 at 9:29