comparison plugins/mod_s2s.lua @ 13987:4067a95336dd

mod_s2s, s2smanager: Experimental s2s_block_immediate_retries option Currently, if Prosody fails to connect to a remote domain, any pending stanzas are bounced back to the sender. If the code processing these stanzas responds to the error, we will begin a new outgoing connection before we've even finished processing the last one. This generally hasn't been a problem, Prosody handles it fine. However, it is questionable whether this is sensible behaviour (if we *just* failed to connect, will an immediate retry even work most of the time?). It can also lead to some awkward traffic patterns, e.g. when combined with MUC. For example, when a MUC receives an error from a remote user, it may kick that user from the MUC. This will cause a stanza to be sent to everyone else in the MUC. If other users from the same domain are present, the notification will be sent to the remote domain, triggering a new connection attempt for no reason (the user was likely about to be kicked anyway after the sendq had finished being bounced). This new option enables an alternative strategy, where attempts to send to the remote domain that failed will be rejected until the sendq has finished being processed. To enable the new behaviour, set the global option: s2s_block_immediate_retries = true
author Matthew Wild <mwild1@gmail.com>
date Thu, 16 Oct 2025 18:29:03 +0100
parents e3ef3e684855
children d4a7cc295363
comparison
equal deleted inserted replaced
13986:107a3d9c147b 13987:4067a95336dd
41 local secure_domains, insecure_domains = 41 local secure_domains, insecure_domains =
42 module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items; 42 module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items;
43 local require_encryption = module:get_option_boolean("s2s_require_encryption", true); 43 local require_encryption = module:get_option_boolean("s2s_require_encryption", true);
44 local stanza_size_limit = module:get_option_integer("s2s_stanza_size_limit", 1024*512, 10000); 44 local stanza_size_limit = module:get_option_integer("s2s_stanza_size_limit", 1024*512, 10000);
45 local sendq_size = module:get_option_integer("s2s_send_queue_size", 1024*32, 1); 45 local sendq_size = module:get_option_integer("s2s_send_queue_size", 1024*32, 1);
46 local block_retries = module:get_option_boolean("s2s_block_immediate_retries", false);
46 47
47 local advertised_idle_timeout = 14*60; -- default in all net.server implementations 48 local advertised_idle_timeout = 14*60; -- default in all net.server implementations
48 local network_settings = module:get_option("network_settings"); 49 local network_settings = module:get_option("network_settings");
49 if type(network_settings) == "table" and type(network_settings.read_timeout) == "number" then 50 if type(network_settings) == "table" and type(network_settings.read_timeout) == "number" then
50 advertised_idle_timeout = network_settings.read_timeout; 51 advertised_idle_timeout = network_settings.read_timeout;
239 -- Create a new outgoing session for a stanza 240 -- Create a new outgoing session for a stanza
240 function route_to_new_session(event) 241 function route_to_new_session(event)
241 local from_host, to_host, stanza = event.from_host, event.to_host, event.stanza; 242 local from_host, to_host, stanza = event.from_host, event.to_host, event.stanza;
242 log("debug", "opening a new outgoing connection for this stanza"); 243 log("debug", "opening a new outgoing connection for this stanza");
243 local host_session = s2s_new_outgoing(from_host, to_host); 244 local host_session = s2s_new_outgoing(from_host, to_host);
245 if block_retries then
246 host_session.block_retries = true;
247 end
244 host_session.version = 1; 248 host_session.version = 1;
245 249
246 -- Store in buffer 250 -- Store in buffer
247 host_session.bounce_sendq = bounce_sendq; 251 host_session.bounce_sendq = bounce_sendq;
248 host_session.sendq = queue.new(sendq_size); 252 host_session.sendq = queue.new(sendq_size);