Dead connection message and delivery receipt received delay in stream management - MongooseIM server 2.0.0

876 Views Asked by At

I have enable stream management in both side client or server. I have two users A and B. Both users are online.Then user A suddenly lose his connection. but A user still appear online on user B and as well as on server. During that time user B sending message on user A. Those message are not lost but when user A is appear online again it will receive those message after 2-3 minute.and i will get message stanza on Offline storage and delivery receipt i will got on SM storage.This issue same occur on one to one chat and mucLight. have i need to customized any mongooseIM modules. Please guide me why users received delay message when their are lost his connection. is it possible to changed SM storage to offline storage(MAM). here's link for same issue i have found same issue on this link (https://www.ejabberd.im/faq/tcp) but have not lost my messages but just received it delay.

I am use smack-4.2 lib on my Android app.and following code used to enabled stream management in XMPPTCPConnection.

  static{
        XMPPTCPConnection.setUseStreamManagementDefault(true);
        XMPPTCPConnection.setUseStreamManagementResumptionDefault(true);
   }

Here's my ejabbered.cfg file for mod_stream_management module

      {mod_stream_management, [
                       % default 100
                       % size of a buffer of unacked messages
                       % {buffer_max, 100}

                       % default 1 - server sends the ack request after each stanza
                       % {ack_freq, 1}

                       % default: 600 seconds
                       % {resume_timeout, 600}
                      ]},

I have also enable following module on my config file

   %% Only archives for c2c messages, good performance.
  {mod_mam_odbc_user, [pm]},
  {mod_mam_cache_user, [pm]},
% {mod_mam_mnesia_dirty_prefs, [pm]},
% {mod_mam_odbc_arch, [pm, no_writer]},
  {mod_mam_odbc_async_pool_writer, [pm]},
  {mod_mam, []}

I found little solution here smack connect to xmpp server with previous stream id but its not work on mongooseIM-2.0 server.

Thank you in advanced.

2

There are 2 best solutions below

1
On

Did you try using mod_ping and configure on ejabbered.cfg file.

{mod_ping, [{send_pings, true}]},

fore more details please follow this link mod_ping

3
On

I'm assuming below that user A, when they reconnect, is not using Stream Resumption (as defined by XEP-0198: Stream Management) and merely starting a new session. This means that on the server side there's still a dangling process waiting for Stream Resumption to happen. When user A is already reconnected to the server, the dangling process times out (which takes resume_timeout seconds) and sends the messages it had stored for delivery in the outgoing message buffer.

If you don't like this behaviour, you can do one of these:

a) (not advised) disable Stream Management and send a Message Archive Management query (that is use mod_mam) to have the most up to date conversation state each time you establish a new connection to the server

b) leave Stream Management enabled, but use Stream Resumption if only possible; that is, you always try to resume the previous session, unless you don't have the previous session ID or the server rejects the resumption request; ideally you would also use Message Archive Management

c) use Delayed Delivery aka mod_offline, but risk that in some rare cases, if you use multiple devices, the messages might be sent to a wrong device; for example, if you have a phone and a laptop, it might happen that your messages will reach the laptop, but never reach the phone