powered by Jive Software

Android Smack client suddenly sends Unavailable PRESENCE for no reason, then server thinks i'm offline

android

#1

I am using Smack version 4.2.3 for android
I am working with openfire 4.2.2 server.
In the server i have configured Client Connection - Idle Connections Policy - Disconnect client after 30 seconds + Send an XMPP ping request to idle clients.

In the client, I have set a stable XMPPConnection with a ReconnectionManager enabled, and a ConnectionListener that reports each connect/reconnect/disconnect event.

I am connected to the server with my client with username: john@test.com.
When I look at the packets with Wireshark going back and forth from the server to the client, I can see the ping requests and my ping results every 15 seconds and thus the server sees me as Online.
However, after about 10 minutes, suddenly I get a PRESENCE packet from the server of type Unavailable from john to john and then immediately the server sees me as Offline.
In my client I never deliberately send an Unavailable presence, except when I call connection.disconnect().
Also, in the client’s connectionListener I do not see any action when this happens, and the pings keep going back and forth even after this happens, yet the server still thinks I am offline.

Anybody have any idea why is this happening?

Thanks.


#2

I think this may cause problems, but I’m not an expert.


#3

Hi, We also facing same issue, any solutions you found for this problem.

Thanks
Mohsin


#4

Same here, as @fuxuhew said, this is happening since 4.2


#5

Is it problem in Openfire or Smack client library. This leads to some major issue in productions.

Thanks
Mohsin


#6

It should be easy to figure that out by looking at the stanza trace.


#7

I have been tracking this issue for a while. After compare the Spark’s debugger console and my Android Studio project log, the only difference that I found is that spark client is sending a ping every 3 mins.

Openfire is configured to “Disconnect clients after they have been idle for 360 seconds”, and “Send an XMPP Ping request to idle clients”.

Turns out that if I disable previous settings (using “Do not disconnect clients that are idle”) client (Smack) don’t sends unavailable presence anymore.


#8

Are you sure that Smack explicitly sends an unavailable presence? Or does it just look that way?


#9

Hi Flow, sorry for the late answer, working on Markable messages made me forget about this xD.

Answering your question, is OF the one who is sending that stanza. Smack by default send back an answer to server ping (1), but like I said, the difference between my app and Spark is that the last one is sending a ping every 3 mins.

So I think that there is a bug with OF and idle clients configurations.

(1) this is an example of the stanza sent by smack:

<iq to='xxxxxdev12345666' id='342-7182' type='result'></iq><r xmlns='urn:xmpp:sm:3'/>

#10

Bad news:
Even checking Do not disconnect clients that are idle in OF configurations, smack is recv a stanza that he never sent, a unavailable presence from him to him.
We added listeners to connection for incoming and outgoing stanzas and the only one captured was the RECV one.

@atmohsin, @Paul_Schaub, @Flow