使用扭曲的重新连接clientfortory并且连接丢失时,我需要从ClientConnectionLost方法中调用Connector.Connect()或者自动发生这种情况?

答案可能似乎是显而易见的,因为它是毕竟,重新连接clientfactory 但是扭曲的文档说了一个 这里 ,我想知道:

“调用Connector.Connect()可能是有用的 - 这将重新连接。”

术语'可能是有用的措辞,因为基本客户端工厂的API Doc表示同一件事。

max的答案是正确的,但在进一步研究之后,我认为“校正器”答案如下:

def clientConnectionLost(self, connector, reason):
    # do stuff here that is unique to your own requirements, then:
    ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
.

这允许您完成应用程序所需的专业内容,然后调用进出工厂代码以允许扭曲以处理为您调用Retry()。

有帮助吗?

解决方案

我的旧答案并不完全正确。而是这样做:

def clientConnectionLost(self, connector, reason):
    # do stuff here that is unique to your own requirements, then:
    ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
.

这允许您进行应用程序所需的专业内容 然后呼入工厂代码以允许扭曲以照顾 为您调用Retry()。

其他提示

调用重新连接clientfactory.clientConnectionLost(Self,Connector,原因)是正确的事情,如图所示:

    在调用self.retry之前检查“self.contilying”(这是 关键,因为连接可能因呼叫而丢失 'stoptrying()'
  1. 将self.contor设置为传入的连接器。
  2. 调用self.retry()(由于缺少传递的连接器使用self.connector设置在#2中)。
  3. ,如果将来有重新连接的COLCNectingClientFactory实现,那么在重新连接路径中需要更多的操作,它们将自动处理,没有代码更改。
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top