From 2bce3fcf6731cd300557043fdc1c4a6029fd7838 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 19 Apr 2019 10:34:50 +0800 Subject: [PATCH] [Mod]catch socket.error in WebsocketClient --- vnpy/api/websocket/websocket_client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vnpy/api/websocket/websocket_client.py b/vnpy/api/websocket/websocket_client.py index d2187276..6c073b28 100644 --- a/vnpy/api/websocket/websocket_client.py +++ b/vnpy/api/websocket/websocket_client.py @@ -4,6 +4,7 @@ import json import ssl import sys import traceback +import socket from datetime import datetime from threading import Lock, Thread from time import sleep @@ -184,7 +185,8 @@ class WebsocketClient(object): self.on_packet(data) # ws is closed before recv function is called - except websocket.WebSocketConnectionClosedException: + # For socket.error, see Issue #1608 + except (websocket.WebSocketConnectionClosedException, socket.error): self._reconnect() # other internal exception raised in on_packet