0
我無法使用'applicationRunner',因爲它不支持websockets的自動重新連接(GitHub問題:#295#389)。我已經回覆到使用扭曲的「ReconnectingClientFactory」的棄用方法。我的問題是,這種方法似乎不允許我添加'ssl.optionsForClientTLS'來嚴格驗證服務器主機名和證書。有什麼辦法可以做到這一點?AutobahnPython w/Twisted:ssl.optionsForClientTLS on websocket.WampWebSocketClientFactory
真的很感謝您的反饋!
class MyClientFactory(websocket.WampWebSocketClientFactory, ReconnectingClientFactory):
maxDelay = config.maxretry
def clientConnectionFailed(self, connector, reason):
logging.debug("Connection Failed: %s", reason)
ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
def clientConnectionLost(self, connector, reason):
logging.debug("Connection Lost: %s", reason)
ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
def start():
log.startLogging(sys.stdout)
component_config = types.ComponentConfig()
session_factory = wamp.ApplicationSessionFactory(config=component_config)
session_factory.session = MyFrontendComponent
transport_factory = MyClientFactory(session_factory, 'wss://services:8443/ws', debug=True)
transport_factory.debug = True
transport_factory.debugCodePaths = True
websocket.connectWS(transport_factory)
Thread(target=reactor.run, args=(False,)).start()