F
F
f0y2011-01-31 16:01:11
Python
f0y, 2011-01-31 16:01:11

Handling connection loss in Twisted

Good day! The problem is that I can't handle the connection loss situation.
Let me explain with a specific example. I connect my account to the jabber server and start pinging it (wokkel.ping), I add errback to send the ping, in which ConnectionLost is caught. Further I cut off the Internet, a ping continue to go and ConnectionLost is not caught. I forcibly close the connection and then all previously unhandled exceptions are processed. Approximately like this:


It pings normally.
[XmlStream,client] Ping to JID(u'jabber.ru') started at HivemindPingClientProtocol
[-] SEND: "iq to='jabber.ru' type='get' id='H_3'>/>"
[XmlStream, client] RECV: "/><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"

Shut down the internet.
[-] SEND: "iq to='jabber.ru' type='get' id='H_6'>/> "
[-] SEND: "iq to='jabber.ru' type='get' id=' H_7'>/>
»

ConnectionLost is not caught, I forcibly close the connection.



All exceptions are handled after the connection is closed.
[XmlStream,client] Failure [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion.
[XmlStream,client] Failure [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion.]
[XmlStream,client ] Connection lost with [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.]
[XmlStream,client] Stopping factory <hivemind.network.network_core.HivemindXmlStreamFactory object at 0xa2e904c>>


Has anyone encountered such a situation? What am I doing wrong? Actually I'm trying to handle this exception to make a reconnect (break connection + factory starts reconnect). Please help with reconnect.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question