From 48602cff9bb0f8779fa5628222c28eed6d6b3621 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Fri, 13 Aug 2021 11:55:00 +0900 Subject: [PATCH] Fix #1055 Socket Mode: ENOTSOCK every 300 minutes on Windows (#1091) --- slack_sdk/socket_mode/builtin/internals.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slack_sdk/socket_mode/builtin/internals.py b/slack_sdk/socket_mode/builtin/internals.py index a0a5ec16f..c15a6acc1 100644 --- a/slack_sdk/socket_mode/builtin/internals.py +++ b/slack_sdk/socket_mode/builtin/internals.py @@ -204,7 +204,9 @@ def receive(specific_buffer_size: Optional[int] = None): logger.debug(f"Received bytes: {received_bytes}") return received_bytes except OSError as e: - if e.errno == errno.EBADF: + # For Linux/macOS, errno.EBADF is the expected error for bad connections. + # The errno.ENOTSOCK can be sent when running on Windows OS. + if e.errno in (errno.EBADF, errno.ENOTSOCK): logger.debug("The connection seems to be already closed.") return bytes() raise e