Next: , Previous: Modeline status, Up: Useful features

10.3 Keepalive

Sometimes network connections are lost without you noticing. This is especially true with Jabber, as it is quite reasonable to keep the connection open for a long time without either sending or receiving any data.

On the other hand, the server may want to do the same kind of detection, and may expect the client to send something at regular intervals.

If you want to detect a lost connection earlier, or make sure that the server doesn't drop your connection, you can use the keepalive functions. These come in two flavours: whitespace pings and XMPP pings.

10.3.1 Whitespace pings

A whitespace ping is a single space character sent to the server. This is often enough to make NAT devices consider the connection “alive”, and likewise for certain Jabber servers, e.g. Openfire. It may also make the OS detect a lost connection faster—a TCP connection on which no data is sent or received is indistinguishable from a lost connection.

Type M-x jabber-whitespace-ping-start to start it, and M-x jabber-whitespace-ping-stop to stop it. The former is in jabber-post-connect-hooks by default; see Hooks.

The frequency of whitespace pings is controlled by the variable jabber-whitespace-ping-interval. The default value is once every 30 seconds.

10.3.2 XMPP pings

These functions work by sending a ping request to your server once in a while (by default every ten minutes), and considering the connection lost if the server doesn't answer within reasonable time (by default 20 seconds).

Type M-x jabber-keepalive-start to start it, and M-x jabber-keepalive-stop to stop it. You may want to add jabber-keepalive-start to jabber-post-connect-hooks; see Hooks.

You can customize the interval and the timeout with the variables jabber-keepalive-interval and jabber-keepalive-timeout, respectively.