Comparison

plugins/mod_s2s.lua @ 13382:f70311588c77

mod_s2s: Close connection on smacks timeout This merges the mod_s2s_smacks_timeout behavior from prosody-modules This event is fired by mod_smacks when the connection has not responded to an ack-request for a period of time defaulting to 30 seconds, indicating that the connection has become stuck or non-responsive. Closing it prevents routing further messages via this connection and frees resources. A stuck connection may otherwise remain until for a time determined by the OS TCP subsystem, which can be quite long.
author Kim Alvefur <zash@zash.se>
date Sat, 02 Dec 2023 20:20:05 +0100
parent 13298:b7c08f32112c
child 13444:783706350faa
comparison
equal deleted inserted replaced
13381:b7dc45d704fa 13382:f70311588c77
270 session.outgoing_stanza_size_limit = tonumber(limits:get_child_text("max-bytes")); 270 session.outgoing_stanza_size_limit = tonumber(limits:get_child_text("max-bytes"));
271 end 271 end
272 end, 100); 272 end, 100);
273 module:hook("s2s-authenticated", make_authenticated, -1); 273 module:hook("s2s-authenticated", make_authenticated, -1);
274 module:hook("s2s-read-timeout", keepalive, -1); 274 module:hook("s2s-read-timeout", keepalive, -1);
275 module:hook("smacks-ack-delayed", function (event)
276 if event.origin.type == "s2sin" or event.origin.type == "s2sout" then
277 event.origin:close("connection-timeout");
278 return true;
279 end
280 end, -1);
275 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) -- luacheck: ignore 212/stanza 281 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) -- luacheck: ignore 212/stanza
276 local limits = stanza:get_child("limits", "urn:xmpp:stream-limits:0"); 282 local limits = stanza:get_child("limits", "urn:xmpp:stream-limits:0");
277 if limits then 283 if limits then
278 session.outgoing_stanza_size_limit = tonumber(limits:get_child_text("max-bytes")); 284 session.outgoing_stanza_size_limit = tonumber(limits:get_child_text("max-bytes"));
279 end 285 end