Skip to content Skip to sidebar Skip to footer

Reconnect To Different Address In Twisted?

I have a server that sends my client the address of a backup server in case it goes down. On the server side the backup server is running. On the client side once the connection is

Solution 1:

class MyProtocol(Protocol):
    def connectionLost(self, reason):
        print 'Connection Lost'
        print 'Trying to reconnect'
        reactor.connectTCP(
            "localhost", 8001, Factory.forProtocol(MyProtocol),
        )

reactor.connectTCP("localhost", 8000, Factory.forProtocol(MyProtocol))
reactor.run()

Post a Comment for "Reconnect To Different Address In Twisted?"