0
如何捕獲sendMessage錯誤?沒有異常傳播。當服務器關閉(半開連接)時,我想捕獲客戶端代碼中的錯誤。如果運行websocket守護進程的服務器崩潰,重新啓動,丟失網絡連接closeConnection/ConnectionLost/ConnectionFailed回調不起作用。Autobahn:catch sendMessage錯誤
from autobahn.websocket import WebSocketClientProtocol
class ClientProtocol(WebSocketClientProtocol):
def onOpen(self):
def heartbeat():
self.sendMessage("HB")
self.factory.reactor.callLater(1, heartbeat)
# I want to catch a socket error
try:
heartbeat()
except Exception as e:
print e
也許有比這更好的解決方案。乒乓 ?只是我無法找到一種方式,我的客戶端可以檢測到服務器崩潰/重新啓動,然後重新連接。
我使用高速公路0.6.5
WebSocketClientProtocol(0.9.4-2)中的_sendAutoPing中缺少callLater。沒有它,客戶端不支持自動功能。我添加了它,現在一切正常。謝謝 – se7en
如果是這樣的話,你能否提出問題並做一個公關? – oberstet