powered by Jive Software

Stream is not resuming

Hi guys,
I am using smack to build a chat app for android.
I am not able to resume the previous stream as a result i am facing a potential message loss. Here is what i am able to understand throgh my debugging.

  1. I am able to connect and login to the server(ejabberd) .
  2. I have manually set the resource in the configuration. But it different for different phones.
  3. I am using stream management and it succsessfully using stream.
  4. When disconnect and reconnect, a new connection is established. But on the server i am getting the error
Stream closed by local host: Replaced by new connection (conflict)

i know this error tells us that a different client is logged in with same resource. But i have never changed the device. I have kept the resource at the same everytime i connect the server.

So i think what actually happens when we disconnecrt and reconnect, the server sees us a different client but with the same resource name. As if i do not reset the resource manually, resource name changes everytime i connect. and hence i am unable to resume the session .

What is i am missing so that i can bind my resource to the device and everytime i refresh the server sees me as single client with the same resource name.
Please suggest some technique as this has got me so crazy i have begin to pull my hair. :sweat_smile:

Thanks

Are you sure that the log message you get on your server means that Stream Resumption is not working?

@Paul_Schaub you point out right. I came to know this when when i debugged the problem.
The issue was when i first run the app it connects and set up stream managment with resume=“true” .

But then i turn the mobile net (4G/WiFi) it attempts reconnection (ReconnetionManager).
I turn the mobile internet on and logs what’s happening.

In logs It can be seen that it on reconnection first enable request is sent (multiple times) and after sometime when it resumes the previous stream(with stream id before disconnection) we get Item not exist and makes complete sense. this all happens when the connection has been re-established successfully .

What i am doing wrong i am not able to debug. I am posting my code and logs in the a file. Please help what me figure out what it is i am doing wrong in the code.

For simplicity I have labelled different parts of the logs in the
file.

logs.txt (197.4 KB)

RoasterConnection.java (21.3 KB)

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.