How do I configure keepalive for client to server XMPP connections?

Hello,

Environment: Debian Linux, .rpm package converted to .deb with alien -c (I am not too good at Debian and with the new, native debian package I had some dependency problem, etc.). Openfire 3.4.3.

I use Openfire with a J2ME application. The application prompted internet connection dialogue, whenever the client to server timeout happened. Somehow I learned (using the source code) that this timeout is 6 minutes by default and that I can fix it by adding the property of “xmpp.client.idle” with value 0 from the admin web interface. This is in milliseconds, setting it 0 will result in no timeout.

However, with this timeout disabled, after a while (about 2 hours and 10 minutes if my measurement was correct) a TCP timeout happens, which can be seen from the debug log:

2008.01.11 00:37:57 ConnectionHandler:

java.io.IOException: Connection timed out

at sun.nio.ch.FileDispatcher.read0(Native Method)

at sun.nio.ch.SocketDispatcher.read(Unknown Source)

at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)

at sun.nio.ch.IOUtil.read(Unknown Source)

at sun.nio.ch.SocketChannelImpl.read(Unknown Source)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.j ava:218)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcesso r.java:198)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProce ssor.java:45)

at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProce ssor.java:485)

at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

I left this connection open for the night, and in the morning I tried to send a chat message to the client. Openfire fails to route the packet:

2008.01.11 08:38:14 RoutingTableImpl: Failed to route packet to JID:

<packet content>

(When I restarted the client application the message was delivered.)

I receive no exception in the J2ME application about this timeout. I will need to check whether I can fix it with client side keepalive.

But the question arises: is there a way to configure the keepalive settings for the client to server XMPP connections in Openfire and if yes how?

Thanks for any help in advance.

Attila

When you log into openfire admin, under System Properties add a new one:

xmpp.client.idle -1

where -1 means the idle timeout is disabled. You can also specify the timeout in miliseconds.

For complete list of system properties, check out this link:

Cheers

Marko

1 Like

Marko,

How can I find out what the maximum allowed keep alive interval is for a server (let’s say gtalk). I can see that the gtalk server sends me a keep alive every 300 seconds when I don’t send it any keep alives. This seems to be enough tp keep the socket open. Do you think I can rely on the server’s keep alive and set my xmpp.client.idle to -1?

Thanks Marko

-Amir

And while we’re on this topic, does anyone know if I can ask the gtalk server to increase the keep-alive interval that it sends me? In other words is there a way for me to ask the server to send me keep alives every 10 minutes instead of every 5?

Thanks,

-Amir

Hi Amir,

It sounds like you’re using gtalk server as opposed to Openfire. As far as I know, gtalk servers are administered by Google and you cannot change their server settings, for obvious reasons. So, if you’re using gtalk jabber account, then you shouldn’t worry about keep-alive because that’s all handled by gtalk.

What I was refering to in my original post is Openfire acting as a server for your Jabber client, in which case you have access to all server settings.

Cheers

Marko

Also if you look at Openire properties link from my first post, you’ll see that Openfire default idle timeout is 6 * 60 * 1000 milliseconds, or 6 minutes.

Marko