tags:

views:

196

answers:

2
+1  Q: 

IMAP Idle Timeout

Lets say I am using IMAP IDLE to monitor changes in a mail folder.

The IMAP spec says that IDLE connections should only stay alive for 30 minutes max, but it is recommended that a lower number of minutes is selected - say 20 minutes, then cancel the idle and restart.

I am wondering what would happen if the mail contents changed between the idle canceling, and the new idle being created. An email could potentially be missed. Given that RECENT is a bit vague, this could lead to getting a message list before the old idle ends, and a new idle starts.

But this is almost the same as polling every 20 minutes, and defeats some of the benefit of idle.

Alternatively, a new idle session could be started prior to terminating the expiring one.

But in any case, I think this problem has already been solved so here I am asking for recommendations.

Thanks,

Paul

+1  A: 

As you know, the purpose of IMAP IDLE command (RFC 2177) is to make it possible to have the server transmit status updates to the client in real time. In this context, status updates means untagged IMAP server responses such as EXISTS, RECENT, FETCH or EXPUNGE that are sent when new messages arrive, message status is updated or a message is removed.

However, these IMAP status updates can be returned by any IMAP command, not just the IDLE command - for example, the NOOP command (see RFC 3501 section 6.1.2) can be used to poll for server updates as well (it predates the IDLE command). IDLE only makes it possible to get these updates more efficiently - if you don't use IDLE command, server updates will simply be sent by the server when the client executes another command (or even when no command is in progress in some cases) - see RFC 3501 section 5.2 and 5.3 for details.

This means that if a message is changed between the IDLE canceling and the new IDLE command, the status updates should not be lost, just as they are not lost if you never used IDLE in the first place (and use NOOP every few seconds instead, for example) - they should simply be sent after the new IDLE command is started.

Lukas Pokorny
A: 

My translation of this would be "when you re-establish the imap idle, check the status, and if recent, exists etc have not changed, there is no need to look in any greater depth than that. If they have changed, get a new message list."

Is that what you are saying? If so, it sounds totally cool.

Paul