diff 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
line wrap: on
line diff
--- a/plugins/mod_s2s.lua	Wed Oct 15 02:12:51 2025 +0200
+++ b/plugins/mod_s2s.lua	Thu Oct 16 18:29:03 2025 +0100
@@ -43,6 +43,7 @@
 local require_encryption = module:get_option_boolean("s2s_require_encryption", true);
 local stanza_size_limit = module:get_option_integer("s2s_stanza_size_limit", 1024*512, 10000);
 local sendq_size = module:get_option_integer("s2s_send_queue_size", 1024*32, 1);
+local block_retries = module:get_option_boolean("s2s_block_immediate_retries", false);
 
 local advertised_idle_timeout = 14*60; -- default in all net.server implementations
 local network_settings = module:get_option("network_settings");
@@ -241,6 +242,9 @@
 	local from_host, to_host, stanza = event.from_host, event.to_host, event.stanza;
 	log("debug", "opening a new outgoing connection for this stanza");
 	local host_session = s2s_new_outgoing(from_host, to_host);
+	if block_retries then
+		host_session.block_retries = true;
+	end
 	host_session.version = 1;
 
 	-- Store in buffer