How do I send regular heartbeat packets to the server so it won't disconnect the client?

i am getting disconnected (smack 3.2.0 and openfire 3.7.0) after a while even though i have set openfire to not disconnect users. i was reading on the internet a bit about XMPP ping and pong, and also, from reading this page, http://community.igniterealtime.org/docs/DOC-2053, it seems that the client can send regular “heartbeat” packets to the server.

how can i do send regular heartbeat packets to the server so it won’t disconnect me?

also, i read this page, http://code.google.com/p/asmack/issues/detail?id=47, and one user gives some teasing information on how to implement the ping pong process (on the client), but not enough details for me to actually go. will this make a difference in keeping my connection alive if i persue this route?

1 Like

i dont think so.

i havent seen spark send the “Ping”-Packet until yet

@wolf, do you mean that openfire doesn’t send the ping? (because the web UI gives you an option to send ping). or do you mean that spark doesn’t send the pong?

http://xmpp.org/extensions/xep-0199.html#c2s

spark doesnt send ping to the server

Smack does that already. Have a look at SmackConfiguration.setKeepApliveInterva()l and PacketWriter.startKeepAliveProcess(). It’s not an XMPP Ping but just an whitespace that is send. But IIRC this should be enough for Openfire to notice the connection as alive.

Was wondering, if Spark doesn’t send ping to the server which I too notice it. How come the Openfire doesn’t disconnect it? For my case I set the xmpp.client.idle to 2 mins but it still alive

You can force Openfire to send a disconnect XMPP Ping message before it disconnect the client, assumed that your client will respond back to that disconnect message, that should keep your client connected.

This can be done by configuring Client Connections Idle Connections Policy under Server Settings. by setting the x seconds for “Disconnect clients after they have been idle for” and check “Send an XMPP Ping request to idle clients”.

Hello,

I am using Smack version 4.2.3, Want to send whitespace KeepAlive stanza to ejabberd server, what can I do?
i am send ping by using pingManager to server but our server is not supports ping Module. so want sent whitespace KeepAlive stanza

Thanks in advance

Every XMPP RFC compliant server implicitly supports responding to xep199 pings. I’m confident that your server does too. There is no need for whitespace pings anymore.

Hello,
Thanks for quick Response.

We are using Ejabberd SaaS as our server, it supports ping module but it will cost 1 jab per ping (as stated in their documentation), so I need to send white space stanza to the server to keep connection alive.

Thanks in advance!

My bet is, that a normal stanza would also cost 1 jab as well.

Hello,

As per their documents and ejabberd Server support if i send “Whitespace KeepAlive” stanza it would not cost any jab’s.

So, is there any way to send Whitespace KeepAlive stanza using latest smack version?

Thanks

Depends. How is a whitespace stanza structured? Do you have an example?

Something like this should to the trick

sendStanza(new Stanza() {
  public String toXml(String enclsoingNamespace) { return " "; }
});