From 1cc5c8b16efb47b82ea1888d2af56b19f121d170 Mon Sep 17 00:00:00 2001 From: nanoric Date: Tue, 16 Oct 2018 05:45:16 -0400 Subject: [PATCH] =?UTF-8?q?[Fix]=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AABUG?= =?UTF-8?q?=EF=BC=9AWebSocketClient=E6=97=A0=E6=B3=95=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=EF=BC=9AonDisconnected=E8=B5=8B=E5=80=BC=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/api/websocket/WebSocketClient.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vnpy/api/websocket/WebSocketClient.py b/vnpy/api/websocket/WebSocketClient.py index 1a702a9e..b7ad28fc 100644 --- a/vnpy/api/websocket/WebSocketClient.py +++ b/vnpy/api/websocket/WebSocketClient.py @@ -38,7 +38,7 @@ class WebSocketClient(object): self.host = None # type: str self.onConnected = self.defaultOnConnected - self.onDisconnected = self.onDisconnected + self.onDisconnected = self.defaultOnDisconnected self.onPacket = self.defaultOnPacket self.onError = self.defaultOnError @@ -143,6 +143,9 @@ class WebSocketClient(object): data = json.loads(stream) self.onPacket(data) + except websocket.WebSocketConnectionClosedException: + if self._active: + self._reconnect() except: et, ev, tb = sys.exc_info() self.onError(et, ev, tb)