Closed seanthegeek closed 6 years ago
A connection in IDLE mode must be reactivated periodically, the RFC requires at least every 29 minutes. I personally found 13 minutes to be the sweet spot.
Ah. It would be great if imapclient handled that for you, being a higher-level library. Do you have any example of how to manage that? A threaded timer?
I just checked the docs again and noticed
Note that IMAPClient does not handle low-level socket errors that can happen when maintaining long-lived TCP connections. Users are advised to renew the IDLE command every 10 minutes to avoid the connection from being abruptly closed.
D'oh!
See #324 for an example on how to IDLE and renew many connections at once.
In your case as you appear to have a single connection, you can do something very simple:
import time
start_time = time.monotonic()
responses = server.idle_check(timeout=wait)
if time.monotonic() - start_time > 13*60:
server.idle_done()
server.idle()
Thanks!
I'm trying to use imapclient's IDLE functionality to monitor an inbox hosted in Office 365. I get responses back for the first hour or two of the IDLE session, then something hangs, and pressing ^c results in a
BrokenPipeError
exception as the client tries to sendDONE
. Any idea what is wrong and how to fix it?