# HG changeset patch # User Kim Alvefur # Date 1659489257 -7200 # Node ID f0fe95f9e21ceb7859b4899139c3cfae78bf683d # Parent da151f9af8618147809f19bce12c6f3cbfa3db27 mod_s2s_smacks_timeout: Use mod_smacks to close stale s2s connections diff -r da151f9af861 -r f0fe95f9e21c mod_s2s_smacks_timeout/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_s2s_smacks_timeout/README.md Wed Aug 03 03:14:17 2022 +0200 @@ -0,0 +1,20 @@ +# Introduction + +This module closes s2s connections when +[mod_smacks][doc:modules:mod_smacks] reports that a connection has not +received a timely acknowledgement as requested, indicating that the +connection is broken or the remote server is not responding. + +With the connection closed, the next stanza to be directed to that +server will trigger Prosody to establish a new connection, instead of +queueing it on the potentially broken connection. + +This should prevent messages from being stuck in a queue for a +potentially long time before being bounced back to the sender as +delivery failure reports. + +Normally the amount of time it takes for a broken connection to time out +is determined by TCP. + +If this is deemed sensible behavior then it will likely be merged into +Prosody itself somewhere. diff -r da151f9af861 -r f0fe95f9e21c mod_s2s_smacks_timeout/mod_s2s_smacks_timeout.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_s2s_smacks_timeout/mod_s2s_smacks_timeout.lua Wed Aug 03 03:14:17 2022 +0200 @@ -0,0 +1,8 @@ +module:depends("smacks"); + +module:hook("smacks-ack-delayed", function (event) + if event.origin.type == "s2sin" or event.origin.type == "s2sout" then + event.origin:close("connection-timeout"); + return true; + end +end);