Timeout when trying to append a big/long message into a mailbox

maxime.lorant@...
 

I discovered a weird bug, regarding *some* Gmail IMAP accounts...

For some reason, I am trying to append a message I just sent using the SMTP server (and delete the one automatically set by smtp.gmail.com). It works fine for fairly simple message, but if timeouts after a certain message size. I have not been able to determine the size, but as long as you have an attachment, the timeout is almost always trigerred... It does happen on several Gmail accounts, so it does not seem an isolated case...

Did anyone encounter this? The problem does not come from imapclient but maybe someone has a clue about this... I can't reproduce it on other IMAP servers.

>>> imap = IMAPClient('imap.gmail.com')
>>> # Assume a oauth2_login call here
>>> imap.append('INBOX', 'Subject: Test\r\n\r\n%s' % ('Test test' * 100))           # Small message body, seems OK (appears in my mailbox after)
b'[APPENDUID 634670718 26357] (Success)'
>>> imap.append('INBOX', 'Subject: Test\r\n\r\n%s' % ('Test test' * 100000)) Traceback (most recent call last): File ".../lib/python3.5/site-packages/backports/ssl/core.py", line 201, in _safe_ssl_call return getattr(sock, call)(*args, **kwargs) File ".../lib/python3.5/site-packages/OpenSSL/SSL.py", line 1540, in send self._raise_ssl_error(self._ssl, result) File ".../lib/python3.5/site-packages/OpenSSL/SSL.py", line 1433, in _raise_ssl_error raise WantWriteError() OpenSSL.SSL.WantWriteError During handling of the above exception, another exception occurred: Traceback (most recent call last): File ".../modules/python3.5.2/lib/python3.5/imaplib.py", line 987, in _command self.send(literal) File ".../lib/python3.5/site-packages/imapclient/tls.py", line 171, in send sent = self.sock.send(data) File ".../lib/python3.5/site-packages/backports/ssl/core.py", line 281, in send return _safe_ssl_call(False, self._conn, 'send', data, flags) File ".../lib/python3.5/site-packages/backports/ssl/core.py", line 209, in _safe_ssl_call raise socket.timeout() socket.timeout During handling of the above exception, another exception occurred: Traceback (most recent call last): File ".../python3.5.2/lib/python3.5/code.py", line 91, in runcode exec(code, self.locals) File "", line 1, in File ".../lib/python3.5/site-packages/imapclient/imapclient.py", line 1007, in append unpack=True) File ".../lib/python3.5/site-packages/imapclient/imapclient.py", line 1180, in _command_and_check typ, data = meth(*args) File ".../python3.5.2/lib/python3.5/imaplib.py", line 387, in append return self._simple_command(name, mailbox, flags, date_time) File ".../python3.5.2/lib/python3.5/imaplib.py", line 1180, in _simple_command return self._command_complete(name, self._command(name, *args)) File ".../python3.5.2/lib/python3.5/imaplib.py", line 990, in _command raise self.abort('socket error: %s' % val) imaplib.abort: socket error:

Join imapclient@groups.io to automatically receive all group messages.