Offline messages lost when user refreshes the page or closes the tab
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?
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 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?
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.
Also i just checked with my own websocket using client - offline message are still here after websocket is closed.
@prefiks are you using strophe.js as client?
Yes
@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
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).
Closing for now, as apparently we cannot reproduce the issue.