def connect(self):
time.sleep(random.randrange(0, 2**self.connection_attempts))
self.connection_attempts += 1
# websocket.enableTrace(True)
ws = websocket.WebSocketApp(self.config_server_url,
on_message=self.on_message,
on_error=self.on_error,
on_close=self.on_close)
ws.on_open = self.on_open
if self.config_server_url.startswith("wss://"):
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_REQUIRED,
"ca_certs": ca_cert,
"ssl_version": ssl.PROTOCOL_TLSv1_2,
"keyfile": client_pem,
"certfile": client_crt})
else:
ws.run_forever()
评论列表
文章目录