Chat history is not working properly.
MongooseIM version: 6.1.0
Installed from: Helm chart
Erlang/OTP version: N/A
Hello. I am using bosh from web client and there are two issues now.
- When a user re-login (refresh page), the last message is sent even mam history does have this message. : It causes Individual chat and group chat; it happens more often on group chat.
- When a user sends a message on group chat, a time (using stamp on mam history) is not match
- case 1
: totally wrong
- case 2 : not same as sent time (6 or 7 hours behind, or just random)
[Attachment]
- mongooseim.toml (mam and muc part)
- Server logs (there is no specific errors)
Could you help me to resolve these issues? Thank you for your time.
Hi,
When a user sends a message on group chat, a time (using stamp on mam history) is not match
What do you mean? Please, post more details (stanzas, ids and what time is and should be)
Hi,
Thank you for the response.
This is data in mam_muc_message
and this is stanza from response of MAM
I tested it around 3 weeks ago and it shouldn't be 1970.
If there is anything I need to add, please let me know.
Thank you.
yes, looks like somehow we ended up encoding timestamp as 0.
Could be a bug in mod_mam_utils:generate_message_id(TS) (TS is provided 0). It gets it from Activity#activity.message_time in mod_muc_room.
Do you use mod_muc or mod_muc_light by the way?
I am using a mod_muc now.
same_mam_id_for_peers=true could be a reason.
Oh, I will change and test it. Thank you.
Hi, I've tried to reproduce it, and unable to. So, maybe more info would help. Do you send message using XMPP API or graphql?
Hi arcusfelis, I am using Strophe.js library on client side. It is working fine with 4.2 since 2021.
If you can easily reproduce ARCHIVING error, you can try to trace the error.
- Open mongooseim shell (i.e.
mongooseim debug). - Enable tracing and wait to check what you got:
recon_trace:calls({mongoose_hooks, filter_room_packet, return_trace}, 1000, [{scope, global}]).
Just wanna confirm timestamp = 0 would be in traced logs.
OK, I actually traced it.
when=2024-06-03T19:52:43.956382+00:00 level=error what=filter_room_packet pid=<0.7249.0> at=mod_muc_room:broadcast_room_packet/5:909 event_data_from_nick=unique_carol_unnamed_171_same_stanza_id_for_muc_172_nickname event_data_room_jid="{jid,<<\"room-ac8811f7ab\">>,<<\"muc.localhost\">>,<<>>}" event_data_affiliation=owner event_data_role=moderator event_data_from_jid="{jid,<<\"carol_unnamed_171_same_stanza_id_for_muc_172\">>,<<\"localhost\">>,<<\"res1\">>}" event_data_timestamp=0 packet="{xmlel,<<\"message\">>,[{<<\"type\">>,<<\"groupchat\">>},{<<\"to\">>,<<\"[email protected]\">>}],[{xmlel,<<\"body\">>,[],[{xmlcdata,<<\"Hi!\">>}]}]}"
So, filter_room_packet is called with timestamp=0 (i.e. event_data_timestamp=0 in the logs).
after that we call:
generate_message_id(CandidateStamp) ->
NodeNum = mongoose_node_num:node_num(),
UniqueStamp = mongoose_mam_id:next_unique(CandidateStamp),
i.e. generate_message_id(0). mongoose_mam_id:next_unique(0)..
If node just started we get:
mod_mam_utils:generate_message_id(0).
257
But if node was already working and processed some regular messages we get the bug hiding itself (or fixing itself):
mod_mam_utils:generate_message_id(erlang:system_time(microsecond)).
439665894343957761
(mongooseim@localhost)3> mod_mam_utils:generate_message_id(0).
439665894343958017
Fix would be probably to set timestamp to erlang:system_time(microsecond) in MUC activity logic (which is some old weird code).
As side effects, you can also get timestamps for MUC messages set to the timestamp of the last sent private message (i.e. 8 hours in the past or just random).
Also, funny numbering:
mod_mam_utils:generate_message_id(0).
257
(mongooseim@localhost)2> mod_mam_utils:generate_message_id(0).
513
(mongooseim@localhost)3> mod_mam_utils:generate_message_id(0).
769
(mongooseim@localhost)4> mod_mam_utils:generate_message_id(0).
1025
Hi, the fix has been merged into the master branch.
Thank you so much for fixing it. I will pull 6.1 version image and test it.
Hi, the fix has been merged into the master branch.
Hi Arcusfelis, I checked docker.io and Digest is same as before. Where can I get an image with this fix? Thank you.
I am using version 6.2.1 tag 4357 and it seems fixed this issue. Thank you so much.