Skip to content

Commit 814da3c

Browse files
authored
Fix #1181 Add exception handling for socket mode - socket.timeout: the read operation timed out (#1182)
1 parent 9853614 commit 814da3c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

slack_sdk/socket_mode/builtin/connection.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,15 @@ def connect(self) -> None:
173173
raise
174174

175175
except Exception as e:
176-
self.logger.exception(
177-
f"Failed to establish a connection (session id: {self.session_id}, error: {e})"
178-
)
176+
error_message = f"Failed to establish a connection (session id: {self.session_id}, error: {e})"
177+
if self.trace_enabled:
178+
self.logger.exception(error_message)
179+
else:
180+
self.logger.error(error_message)
181+
182+
if self.on_error_listener is not None:
183+
self.on_error_listener(e)
184+
179185
self.disconnect()
180186

181187
def disconnect(self) -> None:

0 commit comments

Comments
 (0)