[Twisted-Python] Closing Jabber connection

Ralph Meijer twisted at ralphm.ik.nu
Tue May 3 06:56:35 EDT 2005


On Mon, May 02, 2005 at 11:43:05AM -0300, Carolina Ardohain wrote:
> I try to launch several jabber connections (BTW I use twisted 1.3).
> When the login is successful there's no problem, but whe the password
> is wrong I wanna to disconnect, I call connector.disconnect() but the
> event client.BasicAuthenticator.AUTH_FAILED_EVENT keep calling again
> and again. How I should close the connection so that event don't be
> called anymore?

Calling connector.disconnect() will only close the current connection.
Since the factory returned by client.basicClientFactory is derived from
twisted.internet.protocol.ReconnectingClientFactory, it will happily
retry connecting unless you tell it not to.

Solution: in onAuthFailed(), call self.factory.stopTrying().

By the way, as maintainer of the Jabber stuff in Twisted I can say that
there a fair number of issues in the twisted 1.3 implementation. All of
them have all been resolved in 2.0, and I strongly recommend you to
migrate your work to this.

-- 
Groetjes,

ralphm




More information about the Twisted-Python mailing list