sessionmanager: Make session.send() return true unless there really is an error ...
[prosody.git] / plugins / mod_bosh.lua
index f2b7f458e0dc87549e0b266a7b3e8b03471e50b3..d9c8defd90ead6d891c5948ede45d90e04ce98a0 100644 (file)
@@ -20,6 +20,8 @@ local logger = require "util.logger";
 local log = logger.init("mod_bosh");
 local initialize_filters = require "util.filters".initialize;
 local math_min = math.min;
+local xpcall, tostring, type = xpcall, tostring, type;
+local traceback = debug.traceback;
 
 local xmlns_streams = "http://etherx.jabber.org/streams";
 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
@@ -36,7 +38,7 @@ local bosh_max_wait = module:get_option_number("bosh_max_wait", 120);
 
 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure");
 
-local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8", ["Connection"] = "keep-alive" };
+local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" };
 
 local cross_domain = module:get_option("cross_domain_bosh", false);
 if cross_domain then
@@ -352,6 +354,7 @@ function stream_callbacks.streamopened(context, attr)
        end
 end
 
+local function handleerr(err) log("error", "Traceback[bosh]: %s", traceback(tostring(err), 2)); end
 function stream_callbacks.handlestanza(context, stanza)
        if context.ignore then return; end
        log("debug", "BOSH stanza received: %s\n", stanza:top_tag());
@@ -361,7 +364,9 @@ function stream_callbacks.handlestanza(context, stanza)
                        stanza.attr.xmlns = nil;
                end
                stanza = session.filter("stanzas/in", stanza);
-               core_process_stanza(session, stanza);
+               if stanza then
+                       return xpcall(function () return core_process_stanza(session, stanza) end, handleerr);
+               end
        end
 end