-1

I'm using xiff_3_1_0 to create an XMPP chat client connected to an openfire server.

Everything is working fine so far, except that I could not find a good way to implement the keep-alive signals correctly. There is a function named sendKeepAlive - in class XMPPConnection, but it seems that this relies on the ping-extension being supported by the server.

Actually, there is a TODO in the API documentation stating:

Sends ping to server in order to keep the connection alive, in case the server has not indicated that it would not support it. TODO: Whitespace keepalive if ping not supported...

Is there an elegant way to send a whitespace keep-alive message using xiff_3_1_0?

Alternatively, is there a way to enable the ping extension on an openfire server?

Hulk
  • 6,399
  • 1
  • 30
  • 52

1 Answers1

1

Actually you do not need to know that the server supports the ping extension (XEP-0199) before you use it. If it does not support it then the server will return an error reply, which serves just fine as a "pong".

The benefit of whitespace is that it is very lightweight, but it acts as a keep-alive rather than a ping. The best approach is to use both as necessary.

MattJ
  • 7,924
  • 1
  • 28
  • 33
  • My problem is that the connection got disconnected after a few minutes despite invoking `sendKeepAlive` - I can reconnect, but would prefer not to be disconnected in the first place. – Hulk Dec 04 '13 at 07:16