# HG changeset patch # User Goffi # Date 1450388276 -3600 # Node ID 061011fad5b1bd591274e75fb0abbe42a57143d9 # Parent d2e023da2983537ac604cd9db1f0b1f0217220d3 plugin XEP-0260: better proxy error handling: - display a better message in logs - fixed fallback to IBB diff -r d2e023da2983 -r 061011fad5b1 src/plugins/plugin_xep_0260.py --- a/src/plugins/plugin_xep_0260.py Thu Dec 17 22:10:53 2015 +0100 +++ b/src/plugins/plugin_xep_0260.py Thu Dec 17 22:37:56 2015 +0100 @@ -50,7 +50,9 @@ class ProxyError(Exception): - pass + + def __str__(self): + return "an error happened while trying to use the proxy" class XEP_0260(object): @@ -157,7 +159,8 @@ iq_elt, transport_elt = self._j.buildAction(self._j.A_TRANSPORT_INFO, session, content_name, profile) transport_elt.addElement('proxy-error') iq_elt.send() - log.warning(u"Can't activate proxy, we need to fallback to IBB") + log.warning(u"Can't activate proxy, we need to fallback to IBB: {reason}" + .format(reason = stanza_error.value.condition)) client = self.host.getClient(profile) self.doFallback(session, content_name, client) @@ -264,6 +267,19 @@ if content_data['senders'] == session['role']: # we can now start the file transfer (or start it after proxy activation) d.addCallback(lambda dummy: choosed_candidate.startTransfer(transport_data['session_hash'])) + d.addErrback(self._startEb, session, content_name, client) + + def _startEb(self, fail, session, content_name, client): + """Called when it's not possible to start the transfer + + Will try to fallback to IBB + """ + try: + reason = unicode(fail.value) + except AttributeError: + reason = unicode(fail) + log.warning(u"Cant start transfert, we'll try fallback method: {}".format(reason)) + self.doFallback(session, content_name, client) def _candidateInfo(self, candidate_elt, session, content_name, transport_data, client): """Called when best candidate has been received from peer (or if none is working) @@ -320,7 +336,7 @@ if proxy_elt.name == 'activated': activation_d.callback(None) else: - activation_d.errback(ProxyError) + activation_d.errback(ProxyError()) @defer.inlineCallbacks def jingleHandler(self, action, session, content_name, transport_elt, profile):