fix: websocket shutdown failure
If a heartbeat timeout or connection failure occurs, the shutdown logic
was using original functionality (unwrap), which doesn't exist for
websocket. This internally caught except then put the thread in a bad
state where the consumer of the transport could not try to reconnect.
@@ -170,22 +170,8 @@ class WSTransport(BaseTransport):
"""
self.running = False
if self.socket is not None:
- if self.__need_ssl():
- #
- # Even though we don't want to use the socket, unwrap is the only API method which does a proper SSL
- # shutdown
- #
- try:
- self.socket = self.socket.unwrap()
- except Exception:
- #
- # unwrap seems flaky on Win with the back-ported ssl mod, so catch any exception and log it
- #
- _, e, _ = sys.exc_info()
- logging.warning(e)
- elif hasattr(socket, "SHUT_RDWR"):
try:
- self.socket.shutdown(socket.SHUT_RDWR)
+ self.socket.shutdown()
except socket.error:
_, e, _ = sys.exc_info()
# ignore when socket already closed
