diff -r fd4025e54f4d -r 073136acfeab scansion/objects/client.lua --- a/scansion/objects/client.lua Mon Sep 10 14:55:43 2018 +0100 +++ b/scansion/objects/client.lua Mon Sep 10 14:56:12 2018 +0100 @@ -52,13 +52,20 @@ client.stream:hook("stanza", function (s) client.log("Stanza: %s", s) end); -- Handle unexpected disconnects client.stream:hook("disconnected", function (s) - if not (client.disconnect_expected or client.script.finished) or s.reason then + if not (client.disconnect_expected or client.script.finished) or (s.reason and s.reason ~= "stream closed" and s.reason ~= "closed") then client.log("Unexpected disconnect!"); error("Unexpected disconnect"..(s.reason and " ("..tostring(s.reason)..")" or "")); end end); end; + _finish = function (client) + if client.stream.connected then + client.disconnect_expected = true; + client.stream:close(); + end + end; + connects = function (client) local wait, done = async.waiter(); client.stream:hook("ready", function ()