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