MongooseIM icon indicating copy to clipboard operation
MongooseIM copied to clipboard

Chat history is not working properly.

Open fluttercid opened this issue 1 year ago • 14 comments

MongooseIM version: 6.1.0 Installed from: Helm chart image Erlang/OTP version: N/A

Hello. I am using bosh from web client and there are two issues now.

  1. 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.
  2. When a user sends a message on group chat, a time (using stamp on mam history) is not match
  1. case 1 : totally wrong
    image
  2. case 2 : not same as sent time (6 or 7 hours behind, or just random)

[Attachment]

  • mongooseim.toml (mam and muc part) image
  • Server logs (there is no specific errors) image

Could you help me to resolve these issues? Thank you for your time.

fluttercid avatar Apr 18 '24 14:04 fluttercid

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)

arcusfelis avatar Apr 30 '24 12:04 arcusfelis

Hi, Thank you for the response. This is data in mam_muc_message image and this is stanza from response of MAM image 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.

fluttercid avatar May 01 '24 11:05 fluttercid

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?

arcusfelis avatar May 01 '24 13:05 arcusfelis

I am using a mod_muc now.

fluttercid avatar May 02 '24 11:05 fluttercid

same_mam_id_for_peers=true could be a reason.

arcusfelis avatar May 15 '24 14:05 arcusfelis

Oh, I will change and test it. Thank you.

fluttercid avatar May 17 '24 14:05 fluttercid

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?

arcusfelis avatar Jun 03 '24 16:06 arcusfelis

Hi arcusfelis, I am using Strophe.js library on client side. It is working fine with 4.2 since 2021.

fluttercid avatar Jun 03 '24 18:06 fluttercid

If you can easily reproduce ARCHIVING error, you can try to trace the error.

  1. Open mongooseim shell (i.e. mongooseim debug).
  2. 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.

arcusfelis avatar Jun 03 '24 19:06 arcusfelis

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).

arcusfelis avatar Jun 03 '24 20:06 arcusfelis

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

arcusfelis avatar Jun 03 '24 20:06 arcusfelis

Hi, the fix has been merged into the master branch.

arcusfelis avatar Jun 06 '24 10:06 arcusfelis

Thank you so much for fixing it. I will pull 6.1 version image and test it.

fluttercid avatar Jun 07 '24 11:06 fluttercid

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.

fluttercid avatar Jun 18 '24 16:06 fluttercid

I am using version 6.2.1 tag 4357 and it seems fixed this issue. Thank you so much.

fluttercid avatar Sep 13 '24 15:09 fluttercid