ejabberd icon indicating copy to clipboard operation
ejabberd copied to clipboard

Offline messages lost when user refreshes the page or closes the tab

Open akshaybande81 opened this issue 4 years ago • 8 comments

Discussed in https://github.com/processone/ejabberd/discussions/3734

Originally posted by akshaybande81 December 19, 2021 I am using strophe.js as client for ejabberd server.

The problem I am facing is that, offline messages are lost when user refreshes the page or closes the tab.

I am using anon login. mod_offline is enabled for ejabberd server.

auth_method:
      - odbc
      - anonymous
    allow_multiple_connections: true
    anonymous_protocol: both

Steps to replicate:

login to xmpp with full jid. for ex. [email protected]/resource_1

Send negative present to store offline messages for delayed delivery. Messages are getting stored at this step. I can confirm offline message count > 0 using ejabberd get_offline_count API

As I refresh the page or close the tab, messages are lost. I can confirm this using ejabberd get_offline_count API

If i reconnect again with same jid but different resource for ex. [email protected]/resource_2, I won't receive any of the offline messages.

I am suspecting the ejabberd clears the offline messages for anon users. But I can't find any mention of this online, am I missing something here?

akshaybande81 avatar Dec 20 '21 16:12 akshaybande81

Some ideas:

  • offline messages are cleared after the first client (resource) receives them, afaik
  • try to setup and use MAM instead
  • try to setup IndexDB or something to store in browser the messages

Eg. See how Conversejs does all these, as it's using strophe.js too iirc

licaon-kter avatar Dec 20 '21 17:12 licaon-kter

@licaon-kter offline messages are cleared after the first client (resource) receives them, afaik

I have confirmed that any resource is not available to consume the offline messages. When I close the tab, the resource is not connected to server, then how would offline messages got deleted?

akshaybande81 avatar Dec 21 '21 03:12 akshaybande81

My guess is that your client is sending presence from unload or some other hook when you close tab (maybe with away status?), and since this is positive priority presence that causes ejabberd deliver from offline storage.

prefiks avatar Dec 21 '21 09:12 prefiks

Also i just checked with my own websocket using client - offline message are still here after websocket is closed.

prefiks avatar Dec 21 '21 09:12 prefiks

@prefiks are you using strophe.js as client?

akshaybande81 avatar Dec 21 '21 16:12 akshaybande81

Yes

prefiks avatar Dec 21 '21 17:12 prefiks

@prefiks which login method are you using? Is it happening only for my authentication method?

auth_method:
      - odbc
      - anonymous
    allow_multiple_connections: true
    anonymous_protocol: both

akshaybande81 avatar Dec 22 '21 03:12 akshaybande81

Are your client use anonymous authentication? If so then it's expected that there is no offline storage. If not i think it's really something your client doing, most likely it sends presence with nonnegative priority at some points, and that causes server to flush messages in offline storage, try to capture stanzas that are sent/received by it (they should be visible when ejabberd is set to debug mode, or with some tcp packet dumper).

prefiks avatar Dec 22 '21 09:12 prefiks

Closing for now, as apparently we cannot reproduce the issue.

mremond avatar Jul 11 '23 12:07 mremond