message packet missing form data while fetching from MAM for MUC
Hi, I am fetching the XMPP group messages in Android Client and using MAM for fetching the history;
the message XML is stored in the exact same format as the packet was initially sent but when I am trying to fetch the messages sometimes it's giving the missing media elements which were initially added:
Here is the sample for this case;
Case 1: when I am getting the message successfully in the good format:
<message to="[email protected]/Bleeyy_frQ1R3n2" from="[email protected]">
<result xmlns="urn:xmpp:mam:1" queryid="cc60beef-9f65-4fa2-98f8-6802432f1598" id="1556179624776579">
<forwarded xmlns="urn:xmpp:forward:0">
<delay xmlns="urn:xmpp:delay" stamp="2019-04-25T08:07:04.776+00:00" from="conference.xmpp.bleepyin.com"></delay>
<message from="[email protected]/bleepy01" id="087d1f54-e944-41a3-8608-2cc9d9935584" xml:lang="en" type="groupchat">
<body>https://xmpp.bleepyin.com:5443/upload/66f9d2eeddac256bbfd26b54c30d5d9a807ba529/f2KKeaOlRznDx7gGTh45z5e2hEyMFzoWiUePKPiP/IMG_20190425_133651.jpg</body>
<thread>2BQt9YPr6voq</thread>
<x xmlns="http://jabber.org/protocol/muc#user">
<item jid="[email protected]/Bleeyy_zK0MNwaT"></item>
</x>
<archived xmlns="urn:xmpp:mam:tmp" xmlns:stream="http://etherx.jabber.org/streams" by="[email protected]" id="1556179624776579"></archived>
<stanza-id xmlns="urn:xmpp:sid:0" xmlns:stream="http://etherx.jabber.org/streams" by="[email protected]" id="1556179624776579"></stanza-id>
<x xmlns="jabber:x:data" type="form">
<field label="IMG_20190425_133651.jpg" var="media1"></field>
</x>
</message>
</forwarded>
</result>
</message>
Case 2: when I am getting the message with missing data format:
<message from="[email protected]/bleepy01" id="087d1f54-e944-41a3-8608-2cc9d9935584" xml:lang="en" type="groupchat">
<body>https://xmpp.bleepyin.com:5443/upload/66f9d2eeddac256bbfd26b54c30d5d9a807ba529/f2KKeaOlRznDx7gGTh45z5e2hEyMFzoWiUePKPiP/IMG_20190425_133651.jpg</body>
<thread>2BQt9YPr6voq</thread>
<x xmlns="http://jabber.org/protocol/muc#user">
<item jid="[email protected]/Bleeyy_zK0MNwaT"></item>
</x>
<archived xmlns="urn:xmpp:mam:tmp" xmlns:stream="http://etherx.jabber.org/streams" by="[email protected]" id="1556179624776579"></archived>
<stanza-id xmlns="urn:xmpp:sid:0" xmlns:stream="http://etherx.jabber.org/streams" by="[email protected]" id="1556179624776579"></stanza-id>
<x xmlns="jabber:x:data" type="form">
<field label="IMG_20190425_133651.jpg" var="media1">
<media xmlns="urn:xmpp:media-element" height="4608" width="2176">
<uri type="image/jpeg" size="2976163" duration="0">https://xmpp.bleepyin.com:5443/upload/66f9d2eeddac256bbfd26b54c30d5d9a807ba529/f2KKeaOlRznDx7gGTh45z5e2hEyMFzoWiUePKPiP/IMG_20190425_133651.jpg</uri>
</media>
</field>
</x>
</message>
Note: both messages are fetched in the same client in the same network with same IQ packet but sometimes I get the second type of message;
FYI: I am using MySQL for message archiving;
Thanks
OS? OTP version? ejabberd version? Gist with the config?
To me it looks like that second message is not coming as a result of mam query, but is just regular message that groupchat sends when new message is sent to room.
After brief checking on mam code i am pretty sure it always send that wrapped form in response to queries, there is just no other code paths.
I posted wrong message packet above, Here are the correct ones
Case 1: When a complete message packet comes from Archive.
<message to="[email protected]/Bleeyy_lix3jey4" from="[email protected]">
<result xmlns="urn:xmpp:mam:1" queryid="92ab5789-4603-41cd-b8a3-1db62ca7a462" id="1556179624776579">
<forwarded xmlns="urn:xmpp:forward:0">
<delay xmlns="urn:xmpp:delay" stamp="2019-04-25T08:07:04.776+00:00" from="conference.xmpp.bleepyin.com"></delay>
<message from="[email protected]/bleepy01" id="087d1f54-e944-41a3-8608-2cc9d9935584" xml:lang="en" type="groupchat">
<body>https://xmpp.bleepyin.com:5443/upload/66f9d2eeddac256bbfd26b54c30d5d9a807ba529/f2KKeaOlRznDx7gGTh45z5e2hEyMFzoWiUePKPiP/IMG_20190425_133651.jpg</body>
<thread>2BQt9YPr6voq</thread>
<x xmlns="http://jabber.org/protocol/muc#user">
<item jid="[email protected]/Bleeyy_zK0MNwaT"></item>
</x>
<archived xmlns="urn:xmpp:mam:tmp" xmlns:stream="http://etherx.jabber.org/streams" by="[email protected]" id="1556179624776579"></archived>
<stanza-id xmlns="urn:xmpp:sid:0" xmlns:stream="http://etherx.jabber.org/streams" by="[email protected]" id="1556179624776579"></stanza-id>
<x xmlns="jabber:x:data" type="form">
<field label="IMG_20190425_133651.jpg" var="media1">
<media xmlns="urn:xmpp:media-element" height="4608" width="2176">
<uri type="image/jpeg" size="2976163" duration="0">https://xmpp.bleepyin.com:5443/upload/66f9d2eeddac256bbfd26b54c30d5d9a807ba529/f2KKeaOlRznDx7gGTh45z5e2hEyMFzoWiUePKPiP/IMG_20190425_133651.jpg</uri>
</media>
</field>
</x>
</message>
</forwarded>
</result>
</message>
Case 2: When message packet comes up, but
<message to="[email protected]/Bleeyy_FSx66H6P" from="[email protected]">
<result xmlns="urn:xmpp:mam:1" queryid="8b6da62a-ec32-4824-b9b8-fe71bde17c54" id="1556179624776579">
<forwarded xmlns="urn:xmpp:forward:0">
<delay xmlns="urn:xmpp:delay" stamp="2019-04-25T08:07:04.776+00:00" from="conference.xmpp.bleepyin.com"></delay>
<message from="[email protected]/bleepy01" id="087d1f54-e944-41a3-8608-2cc9d9935584" xml:lang="en" type="groupchat">
<body>https://xmpp.bleepyin.com:5443/upload/66f9d2eeddac256bbfd26b54c30d5d9a807ba529/f2KKeaOlRznDx7gGTh45z5e2hEyMFzoWiUePKPiP/IMG_20190425_133651.jpg</body>
<thread>2BQt9YPr6voq</thread>
<x xmlns="http://jabber.org/protocol/muc#user">
<item jid="[email protected]/Bleeyy_zK0MNwaT"></item>
</x>
<archived xmlns="urn:xmpp:mam:tmp" xmlns:stream="http://etherx.jabber.org/streams" by="[email protected]" id="1556179624776579"></archived>
<stanza-id xmlns="urn:xmpp:sid:0" xmlns:stream="http://etherx.jabber.org/streams" by="[email protected]" id="1556179624776579"></stanza-id>
<x xmlns="jabber:x:data" type="form">
<field label="IMG_20190425_133651.jpg" var="media1"></field>
</x>
</message>
</forwarded>
</result>
</message>
both messages are for the same media file named "IMG_20190425_133651.jpg" but one packet have the complete media information, about url, width, height etc, and the case 2 message packet is missing that
Thanks, this indeed looks suspicious.
Would you be able to attach ejabberd.yml that you are using?
here is the ejabberd.yml
###
### ejabberd configuration file
###
### The parameters used in this configuration file are explained at
###
### https://docs.ejabberd.im/admin/configuration
###
### The configuration file is written in YAML.
### *******************************************************
### ******* !!! WARNING !!! *******
### ******* YAML IS INDENTATION SENSITIVE *******
### ******* MAKE SURE YOU INDENT SECTIONS CORRECTLY *******
### *******************************************************
### Refer to http://en.wikipedia.org/wiki/YAML for the brief description.
### However, ejabberd treats different literals as different types:
###
### - unquoted or single-quoted strings. They are called "atoms".
### Example: dog, 'Jupiter', '3.14159', YELLOW
###
### - numeric literals. Example: 3, -45.0, .0
###
### - quoted or folded strings.
### Examples of quoted string: "Lizzard", "orange".
### Example of folded string:
### > Art thou not Romeo,
### and a Montague?
###
# location: /usr/local/etc/ejabberd
###. =======
###' LOGGING
##
## loglevel: Verbosity of log files generated by ejabberd.
## 0: No ejabberd log at all (not recommended)
## 1: Critical
## 2: Error
## 3: Warning
## 4: Info
## 5: Debug
##
loglevel: 3
##
## rotation: Describe how to rotate logs. Either size and/or date can trigger
## log rotation. Setting count to N keeps N rotated logs. Setting count to 0
## does not disable rotation, it instead rotates the file and keeps no previous
## versions around. Setting size to X rotate log when it reaches X bytes.
## To disable rotation set the size to 0 and the date to ""
## Date syntax is taken from the syntax newsyslog uses in newsyslog.conf.
## Some examples:
## $D0 rotate every night at midnight
## $D23 rotate every day at 23:00 hr
## $W0D23 rotate every week on Sunday at 23:00 hr
## $W5D16 rotate every week on Friday at 16:00 hr
## $M1D0 rotate on the first day of every month at midnight
## $M5D6 rotate on every 5th day of the month at 6:00 hr
##
log_rotate_size: 10485760
log_rotate_date: ""
log_rotate_count: 1
##
## overload protection: If you want to limit the number of messages per second
## allowed from error_logger, which is a good idea if you want to avoid a flood
## of messages when system is overloaded, you can set a limit.
## 100 is ejabberd's default.
log_rate_limit: 100
hosts:
- "xmpp.bleepyin.com"
- "localhost"
certfiles:
- "/usr/local/etc/combined.pem"
define_macro:
# TLS options for client not being able to use modern ciphers (Windows XP+, Android 3.0+)
CIPHERS_INTERMEDIATE: "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS"
PROTOCOL_OPTIONS_INTERMEDIATE:
- "no_sslv2"
- "no_sslv3"
# TLS options for client able to use modern ciphers (Windows 7+, Android 5.0+)
CIPHERS_MODERN: "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256"
PROTOCOL_OPTIONS_MODERN:
- "no_sslv2"
- "no_sslv3"
- "no_tlsv1"
- "no_tlsv1_1"
c2s_ciphers: CIPHERS_INTERMEDIATE
c2s_protocol_options: PROTOCOL_OPTIONS_INTERMEDIATE
listen:
-
port: 5222
ip: "::"
module: ejabberd_c2s
max_stanza_size: 262144
shaper: c2s_shaper
access: c2s
starttls_required: true
-
port: 5269
ip: "::"
module: ejabberd_s2s_in
max_stanza_size: 524288
-
port: 5443
ip: "::"
# certfile: "/usr/local/etc/combined.pem"
module: ejabberd_http
request_handlers:
"upload": mod_http_upload
web_admin: true
captcha: false
ciphers: CIPHERS_INTERMEDIATE
protocol_options: PROTOCOL_OPTIONS_INTERMEDIATE
tls: true
# starttls: true
http_bind: true
-
port: 5280
ip: "::"
# certfile: "/usr/local/etc/combined.pem"
module: ejabberd_http
request_handlers:
"/bosh": mod_bosh
web_admin: true
tls: true
# starttls: true
#-
# port: 1883
# ip: "::"
# module: mod_mqtt
# backlog: 1000
s2s_use_starttls: optional
c2s_tls_compression: true
###. ==============
###' AUTHENTICATION
##
## auth_method: Method used to authenticate the users.
## The default method is the internal.
## If you want to use a different method,
## comment this line and enable the correct ones.
## 9929105282 => 200000, 8890825555 => 200000 10/11/17
#auth_method: sql
auth_method: sql
###
### MySQL server:
###
sql_type: mysql
sql_server: "localhost"
sql_database: "ejabberd"
sql_username: "ejabberd"
sql_password: "ejabberd@123"
##
## If you want to specify the port:
sql_port: 3306
#
default_db: sql
acl:
##
## The 'admin' ACL grants administrative privileges to XMPP accounts.
## You can put here as many accounts as you want.
##
admin:
user:
- "sandeep": "xmpp.bleepyin.com"
- "sandeep": "localhost"
local:
user_regexp: ""
loopback:
ip:
- "127.0.0.0/8"
- "::1/128"
access_rules:
local:
- allow: local
## This rule allows access to upload file on mod_http_upload:
http_upload_acl:
- allow: all
c2s:
- deny: blocked
- allow
announce:
- allow: admin
configure:
- allow: admin
muc:
- allow: all
muc_create:
- allow: local
pubsub_createnode:
- allow: local
register:
- allow
trusted_network:
- allow: loopback
#api_permissions:
# "console commands":
# from:
# - ejabberd_ctl
# who: all
# what: "*"
# "admin access":
# who:
# - access:
# - allow:
# - acl: loopback
# - acl: admin
# - oauth:
# - scope: "ejabberd:admin"
# - access:
# - allow:
# - acl: loopback
# - acl: admin
# what:
# - "*"
# - "!stop"
# - "!start"
# "public commands":
# who:
# - ip: "127.0.0.1/8"
# what:
# - "status"
# - "connected_users_number"
shaper:
normal: 1000
fast: 50000
shaper_rules:
max_user_sessions: 10
max_user_offline_messages:
- 5000: admin
- 10000
c2s_shaper:
- none: admin
- normal
s2s_shaper: fast
modules:
mod_adhoc: {}
mod_admin_extra: {}
mod_announce:
access: announce
mod_avatar: {}
mod_blocking: {}
mod_bosh: {}
mod_caps: {}
mod_carboncopy: {}
mod_client_state: {}
mod_configure: {}
mod_disco: {}
mod_fail2ban: {}
mod_http_api: {}
mod_http_upload:
host: "upload.@HOST@"
name: "HTTP File Uploading"
# access: all
access: http_upload_acl
# thumbnail: true
docroot: "/usr/local/etc/ejabberd/uploads"
put_url: "https://@HOST@:5443/upload"
max_size: infinity
custom_headers:
"Access-Control-Allow-Origin": "*"
"Access-Control-Allow-Methods": "GET, POST, PUT, OPTIONS, DELETE"
"Access-Control-Allow-Headers": "Content-Type, Origin, X-Requested-With"
mod_last: {}
mod_mam:
## Mnesia is limited to 2GB, better to use an SQL backend
## For small servers SQLite is a good fit and is very easy
## to configure. Uncomment this when you have SQL configured:
db_type: sql
default: always
# mod_mqtt: {}
mod_muc:
access:
- allow
access_admin:
- allow: admin
access_create: muc_create
access_persistent: muc_create
access_mam:
- allow
host: "conference.@HOST@"
history_size: 0
default_room_options:
mam: true
allow_user_invites: true
allow_change_subj: true
allow_query_users: true
allow_visitor_status: true
presence_broadcast: [participant, moderator]
max_users: 500
members_by_default: true
persistent: true
allow_subscription: true
mod_muc_admin: {}
mod_offline:
access_max_user_messages: max_user_offline_messages
mod_ping: {}
mod_privacy: {}
mod_private: {}
mod_proxy65:
access: local
max_connections: 5
mod_pubsub:
access_createnode: pubsub_createnode
plugins:
- "flat"
- "pep"
force_node_config:
## Change from "whitelist" to "open" to enable OMEMO support
## See https://github.com/processone/ejabberd/issues/2425
"eu.siacs.conversations.axolotl.*":
access_model: whitelist
## Avoid buggy clients to make their bookmarks public
"storage:bookmarks":
access_model: whitelist
mod_push: {}
mod_push_keepalive: {}
mod_register:
## Only accept registration requests from the "trusted"
## network (see access_rules section above).
## Think twice before enabling registration from any
## address. See the Jabber SPAM Manifesto for details:
## https://github.com/ge0rg/jabber-spam-fighting-manifesto
# ip_access: trusted_network
access: register
mod_roster:
versioning: true
mod_s2s_dialback: {}
mod_shared_roster: {}
mod_stream_mgmt:
resend_on_timeout: if_offline
mod_vcard: {}
mod_vcard_xupdate: {}
mod_version:
show_os: false
### Local Variables:
### mode: yaml
### End:
### vim: set filetype=yaml tabstop=8
@prefiks any idea on this?
Sorry, nothing comes to my mind, tried to reproduce this but each time i get correct result.
Even I am also getting the correct result in 99% cases but there 1 percent race condition where this happens;
My observation: This mostly happens in these scenarios:
- when I am trying to fetch the group chat without joining it (may be some delay in group join)
- in low network
the case i observed here is, if after connection i send the iq for querying the archive immediately, this thing happens 100 times out of 100, but if after connection being connected, and i wait for a while like 10-15 seconds and then i send in the iq for querying the complete packet comes up with all fields.
I've tested this using ejabberd 21.04 and MySQL storage, and worked correctly.
This mostly happens in these scenarios: when I am trying to fetch the group chat without joining it (may be some delay in group join)
if after connection i send the iq for querying the archive immediately, this thing happens 100 times out of 100
I also tried those two cases (request MAM without joining room, and request MAM immediately after logging), and it still works correctly.
Maybe it was related to caching?
BTW, nobody mentioned in what ejabberd version this failed.