[Imap-protocol] Avoiding connection-loss

Mark Crispin mrc at CAC.Washington.EDU
Tue Sep 19 08:58:03 PDT 2006

On Tue, 19 Sep 2006, Arnt Gulbrandsen wrote:

>> [...] clients using IDLE are advised to terminate the IDLE and

>> re-issue it at least every 29 minutes to avoid being logged off.

>> You like cutting things that close?

> Yes. In my professional capacity I need to add workarounds and so on.

> Privately I like to follow the protocol and expect the other guy to do the

> same.

That wasn't the point. Allowing an IDLE to go on for 29 minutes and 50
seconds poses a terrible risk of losing the race with only 10 seconds of

> No. MSN/UID arithmetic. The following sequence is somewhat contrived, but

> it's short and I expect you get the idea:

> S: * 1000 EXISTS

> S: * OK [UIDNEXT 2001]

> S: * 1001 EXISTS

> S: * 1001 EXPUNGE

> S: * 1001 EXISTS


> There is fallback code to handle unexpected UIDNEXT increases, but not

> decreases.

There's a problem with your example. UIDNEXT is only sent at SELECT time.
It is not sent during UID FETCH or other routine operations. Also,
there's no reason to believe that that UID FETCH would work; UIDNEXT is
only a prediction and not a promise.

So you can only be affected if you
(1) keep a mathematical calculation of minimum UIDNEXT as a result of
(2) use that calculation between sessions.

> 1. Your server is the reference implementation. As I understand it, a

> reference implementation is one that implements the protocol completely,

> accurately, meticulously, and above all, without dubious hacks.

It would be easy to achieve this. Elect me Dictator of the World, so I
can outlaw broken IMAP clients that make such kludges necessary!! As
Dictator of the World, I promise a world of only perfect IMAP! ;-)

Of course, there's the small problem that, like Koko in Gilbert &
Sullivan's "The Mikado", "I have a little list"... ;-)

> But wouldn't it be better to extend the 30-minute timeout than to throw a

> spanner in the works of clients that do MSN/UID arithmetic?

I might extend the timeout to 32 minutes if I had evidence that certain
broken clients wouldn't screw up in other ways.

But the question is if any client is actually affected. As noted above,
UIDNEXT is only sent at SELECT time.

-- Mark --

Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.

More information about the Imap-protocol mailing list