powered by Jive Software

SmackConfiguration SetDefaultPingInterval

Hi everyone,

I want to set ping interval that server know that our client still exist.

I set Timeout in openfire server with 10 seconds…

then i continuesly sendPing to server that told him the connection is still exist…

this is my code :

AndroidConnectionConfiguration config = new AndroidConnectionConfiguration(

XMPP_HOST, XMPP_PORT, JID_DOMAIN);

SmackConfiguration.setDefaultPingInterval(5000);

config.setReconnectionAllowed(true);

SASLAuthentication.supportSASLMechanism(“PLAIN”);

config.setSASLAuthenticationEnabled(true);

config.setRosterLoadedAtLogin(true);

mConnection = new XMPPConnection(config);

am i doing wrong?? i want to automatically sent ping to server in interval 5 second…

But i’m always getting connection close from server after 10 seconds.

Thanks before

Please try to add more information to your questions. Parts of the log, exceptions and stacktraces are usually very helpful. Which entity/manager does initiate the disconnect?

hi flow,

the manager that initiate close connection is openfire server.

i manually set it from server… The connection will be closed if the openfire server catch/known that client idle for times that i set on server…(There was no problem with that).

in the client side i want to make client sent ping to server.so that server known client is still available.

i have add SmackConfiguration.setDefaultpinginterval(x)

which is i hope that the client can tell server connection is still exist.

but it seems that client didn’t ping to server.

because i always get connection closed by the server timeout.

any suggestion flow?

I’ve solved this problem using

SmackConfiguration.setKeepAliveInterval(1000 * 30); // 30 sec

in my logs (client)) i see: p. SENT (1111602144) every 30 secs

Regards

The setKeepAliveInterval is the way to accomplish this in Smack. In fact, Smack does actually have the setDefaultPingInterval method at all. It may exist in aSmack, but if it is synced with verion 3.3 of Smack it would dissappear in favor of the keep alive.