esl / MongooseIM

MongooseIM is Erlang Solutions' robust, scalable and efficient XMPP server, aimed at large installations. Specifically designed for enterprise purposes, it is fault-tolerant and can utilise the resources of multiple clustered machines.
Other
1.66k stars 426 forks source link

Cannot resume stream because SMID was previously deleted (`no_previous_session_for_smid` | XEP-0198) #4280

Open hpedrorodrigues opened 3 months ago

hpedrorodrigues commented 3 months ago

MongooseIM version: 6.2.1 Installed from: image Erlang/OTP version: 26


Hey 👋🏻

I'm trying to implement stream resumption, and even though it works most of the time, there are cases where I receive this element:

<failed xmlns='urn:xmpp:sm:3'>
  <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</failed>

This is because MongooseIM cannot find the SMID, but it's not clear the reason.

Example in the logs:

mongooseim-2 mongooseim when=2024-05-17T16:35:44.108910+00:00 level=warning what=resumption_error reason=no_previous_session_for_smid pid=<0.2231.0> at=mod_stream_management:do_handle_resume/5:591 smid=HD/9Rp5MZlPejuwIcw7WFqRd0UGq c2s_state="{c2s_data,<<\"localhost\">>,<<\"localhost\">>,<<\"en\">>,{1715963743730432,<0.2231.0>},<<\"d8a579a8baaf99d3\">>,{jid,<<\"dd316d53-89d7-4657-9630-d9683e755190_guest\">>,<<\"localhost\">>,<<>>},{c2s_socket,mod_websockets,{websocket,<0.2229.0>,{{10,66,8,73},54366},undefined}},{parser,#Ref<0.3472383861.1803419649.72374>,[]},none,#{access => all,port => 5280,hibernate_after => 0,shaper => none,max_stanza_size => 0,ip_tuple => {0,0,0,0},c2s_state_timeout => 15000,backwards_compatible_session => true,proto => tcp,xml_socket => true},#{},#{auth_module => mod_auth_token}}"
mongooseim-1 mongooseim when=2024-05-17T16:37:58.450467+00:00 level=warning what=resumption_error reason=no_previous_session_for_smid pid=<0.2246.0> at=mod_stream_management:do_handle_resume/5:591 smid=nOrlBYZqRRHna2SFTnlBdxmcK3JP c2s_state="{c2s_data,<<\"localhost\">>,<<\"localhost\">>,<<\"en\">>,{1715963877592039,<0.2246.0>},<<\"4aa3e96abff09c09\">>,{jid,<<\"65e71aa6c872d621528016d4\">>,<<\"localhost\">>,<<>>},{c2s_socket,mod_websockets,{websocket,<0.2244.0>,{{10,66,11,16},57094},undefined}},{parser,#Ref<0.2465983669.3682467841.139461>,[]},none,#{access => all,port => 5280,hibernate_after => 0,shaper => none,max_stanza_size => 0,ip_tuple => {0,0,0,0},c2s_state_timeout => 15000,backwards_compatible_session => true,proto => tcp,xml_socket => true},#{},#{auth_module => mod_auth_token}}"

Example in the socket:

Screenshot 2024-05-17 at 15 37 53
mongooseim.toml ```toml # https://esl.github.io/MongooseDocs/latest/configuration/general [general] loglevel = "debug" language = "en" hosts = ["localhost"] default_server_domain = "localhost" registration_timeout = "infinity" rdbms_server_type = "pgsql" sm_backend = "redis" max_fsm_queue = 1000 # https://esl.github.io/MongooseDocs/latest/configuration/listen/ # BOSH (Bidirectional-streams Over Synchronous HTTP | HTTP long-polling) and WebSockets [[listen.http]] ip_address = "0.0.0.0" port = 5280 transport.num_acceptors = 10 transport.max_connections = 1024 [[listen.http.handlers.mod_bosh]] host = "_" path = "/http-bind" [[listen.http.handlers.mod_websockets]] host = "_" path = "/ws-xmpp" # REST client port: https://esl.github.io/MongooseDocs/latest/rest-api/Client-frontend/ [[listen.http]] ip_address = "0.0.0.0" port = 8088 transport.num_acceptors = 10 transport.max_connections = 1024 protocol.compress = true [[listen.http.handlers.mongoose_client_api]] host = "_" path = "/api" [[listen.http.handlers.mongoose_graphql_handler]] host = "_" path = "/api/graphql" schema_endpoint = "user" # REST admin port: https://esl.github.io/MongooseDocs/latest/rest-api/Administration-backend/ [[listen.http]] ip_address = "0.0.0.0" port = 8089 transport.num_acceptors = 10 transport.max_connections = 1024 protocol.compress = true [[listen.http.handlers.mod_websockets]] host = "_" path = "/ws-xmpp" [[listen.http.handlers.mongoose_admin_api]] host = "_" path = "/api" username = "${MONGOOSEIM_USER}" password = "${MONGOOSEIM_PASSWORD}" [[listen.http.handlers.mongoose_graphql_handler]] host = "_" path = "/api/graphql" schema_endpoint = "admin" username = "${MONGOOSEIM_USER}" password = "${MONGOOSEIM_PASSWORD}" # Client-to-server connections [[listen.c2s]] port = 5222 access = "c2s" shaper = "c2s_shaper" max_stanza_size = 65536 [auth] methods = ["rdbms"] sasl_external = ["standard"] [auth.rdbms] users_number_estimate = true [outgoing_pools.redis.default] scope = "global" [outgoing_pools.redis.default.connection] host = "${REDIS_HOST}" port = 6379 database = 0 [outgoing_pools.rdbms.default] scope = "global" [outgoing_pools.rdbms.default.connection] driver = "pgsql" host = "${POSTGRES_HOST}" port = ${POSTGRES_PORT} database = "${POSTGRES_DB_NAME}" username = "${POSTGRES_USER}" password = "${POSTGRES_PASSWORD}" [modules.mod_adhoc] [modules.mod_disco] users_can_see_hidden_services = false [modules.mod_cache_users] [modules.mod_ping] [modules.mod_muc] host = "conference.@HOST@" access = "muc" access_create = "muc_create" backend = "rdbms" default_room.allow_multiple_sessions = true default_room.persistent = true [modules.mod_presence] [modules.mod_mam] muc.backend = "rdbms" backend = "rdbms" no_stanzaid_element = true pm.user_prefs_store = "rdbms" archive_chat_markers = true max_result_limit = 1000 pm.archive_groupchats = true [modules.mod_inbox] backend = "rdbms_async" reset_markers = ["displayed"] groupchat = ["muc"] [modules.mod_muc_log] [modules.mod_muc_light] backend = "rdbms" [modules.mod_stream_management] [modules.mod_last] backend = "rdbms" [modules.mod_roster] backend = "rdbms" [modules.mod_private] backend = "rdbms" [modules.mod_caps] cache_size = 2000 cache_life_time = 10_000 [modules.mod_event_pusher.rabbit] presence_exchange.name = "presence" presence_exchange.type = "topic" chat_msg_exchange.name = "chat_msg" chat_msg_exchange.sent_topic = "mongooseim_chat_msg_sent" chat_msg_exchange.recv_topic = "mongooseim_chat_msg_recv" groupchat_msg_exchange.name = "groupchat_msg" groupchat_msg_exchange.sent_topic = "mongooseim_groupchat_msg_sent" groupchat_msg_exchange.recv_topic = "mongooseim_groupchat_msg_recv" [outgoing_pools.rabbit.event_pusher.connection] host = "${RABBITMQ_HOST}" port = 5672 username = "${RABBITMQ_DEFAULT_USER}" password = "${RABBITMQ_DEFAULT_PASSWORD}" confirms_enabled = false max_worker_queue_len = 1000 [modules.mod_offline_stub] [modules.mod_sic] [modules.mod_vcard] host = "vjud.@HOST@" backend = "rdbms" [modules.mod_auth_token] backend = "rdbms" iqdisc.type = "queues" iqdisc.workers = 20 validity_period.access = {value = 1, unit = "hours"} validity_period.refresh = {value = 25, unit = "days"} [modules.mod_keystore] keys = [{name = "token_secret", type = "ram"}] [shaper.normal] max_rate = 1000 [shaper.fast] max_rate = 50_000 [shaper.mam_shaper] max_rate = 1 [shaper.mam_global_shaper] max_rate = 1000 [acl] local = [{}] [access] max_user_sessions = [ {acl = "all", value = 10} ] max_user_offline_messages = [ {acl = "admin", value = 5000}, {acl = "all", value = 100} ] local = [ {acl = "local", value = "allow"} ] c2s = [ {acl = "blocked", value = "deny"}, {acl = "all", value = "allow"} ] c2s_shaper = [ {acl = "admin", value = "none"}, {acl = "all", value = "normal"} ] muc_admin = [ {acl = "admin", value = "allow"} ] muc_create = [ {acl = "local", value = "allow"} ] muc = [ {acl = "all", value = "allow"} ] mam_set_prefs = [ {acl = "all", value = "default"} ] mam_get_prefs = [ {acl = "all", value = "default"} ] mam_lookup_messages = [ {acl = "all", value = "default"} ] mam_set_prefs_shaper = [ {acl = "all", value = "mam_shaper"} ] mam_get_prefs_shaper = [ {acl = "all", value = "mam_shaper"} ] mam_lookup_messages_shaper = [ {acl = "all", value = "mam_shaper"} ] mam_set_prefs_global_shaper = [ {acl = "all", value = "mam_global_shaper"} ] mam_get_prefs_global_shaper = [ {acl = "all", value = "mam_global_shaper"} ] mam_lookup_messages_global_shaper = [ {acl = "all", value = "mam_global_shaper"} ] [[host_config]] host = "anonymous.localhost" [host_config.auth.anonymous] allow_multiple_connections = true protocol = "both" ```

Sharing these files in case they can help:


Not sure if I'm missing something here. Any help will be appreciated! Thanks. 🙏🏻

JanuszJakubiec commented 1 month ago

Hi, We've recently expanded our tests to cover the usage of mod_stream_management using the WebSockets API. During this process, we identified and fixed some errors and bugs. These changes were included in a recent pull request (https://github.com/esl/MongooseIM/pull/4303) that has already been merged into the master branch. Could you please check if the error is still present in the current master version?

hpedrorodrigues commented 1 month ago

Sure! I'll check the master branch, then. I'll let you know my findings!

JanuszJakubiec commented 2 weeks ago

Hi, have you experienced any issues with stream resumption using WebSockets after the version update? If everything is working fine, I'll proceed with closing the issue.

hpedrorodrigues commented 2 weeks ago

Hi. Yes, I'm still experiencing this issue. I'll collect a few things and will comment here soon.