Repository navigation
IMAP IDLE
2.8 (not in 2.7):
IMAP_USE_IDLEis available from Z-Push 2.8.0.
IMAP_USE_IDLE in src/backend/imap/config.php sets how BackendIMAP waits for changes during a Ping.
-
false(default): the folders are polled everyPING_INTERVALseconds. -
true: one IMAP IDLE (RFC 2177) connection per synchronized folder is kept open, so a change is noticed as soon as the server reports it.
The IMAP server must advertise the IDLE capability.
The IDLE connections follow the transport flags in IMAP_OPTIONS (/ssl, /tls, /notls, /novalidate-cert). Without /notls they are always encrypted: if the server does not offer STARTTLS, IDLE is not used.
If IDLE fails for any reason, the backend logs a warning and polls for the rest of that Ping.
A folder whose connection the server closes during a Ping is reopened and checked for changes. If the connection was closed less than 60 seconds after it was opened, the backend polls for the rest of that Ping instead.
Each Ping keeps its IDLE connections, plus its main IMAP connection, open for its whole lifetime.
A Ping cancelled by the device keeps running on the server (index.php sets ignore_user_abort). It is only ended early, once a newer Ping of the same device arrives, if Z-Push has a working IPC provider (see IPC_PROVIDER in config.php; the default IpcSharedMemoryProvider needs the PHP sysvshm and sysvsem extensions).
Without one, cancelled Pings accumulate connections until the IMAP server refuses new logins, and the device then asks for the password. Gmail allows 15 connections per account; Dovecot's mail_max_userip_connections defaults to 10 per user and IP.
Even with IPC, the older Ping is only ended between two IDLE waits and only if more than 60 seconds of its lifetime remain, so the connections of two Pings can briefly coexist. Allow for about 2 x (folders + 1) connections per user and device.