-
Notifications
You must be signed in to change notification settings - Fork 852
Add exception handling for socket mode - socket.timeout: the read operation timed out #1181
Copy link
Copy link
Closed
Labels
enhancementM-T: A feature request for new functionalityM-T: A feature request for new functionalitysocket-mode
Milestone
Description
I run socket mode with 5 sockets, which works fine, however sometimes I get a timeout, and it gives me a full traceback about socket.timeout.
I'm fine with it right now, as it just opens a new socket connection, however in the logs I'm getting a full traceback.
Are we able to handle this a bit better as it's causing a large amount of logs?
Really I don't care about this, that's why I'd like to just send a message saying it timed out and to continue working, which is why I'd like to handle this better.
This is also related to slackapi/bolt-python#529
2022-02-17 03:38:43.518 | ERROR | slack_sdk.socket_mode.builtin.connection:connect:172 - Failed to establish a connection (session id: d63dd25a-3b4c-4306-a5ac-b3ccabde0ee6, error: The read operation timed out)Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 930, in _bootstrap
self._bootstrap_inner()
│ └ <function Thread._bootstrap_inner at 0x7fb7f5607b80>
└ <Thread(Thread-2, started daemon 140428006546224)>
File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
│ └ <function Thread.run at 0x7fb7f56078b0>
└ <Thread(Thread-2, started daemon 140428006546224)>
File "/usr/local/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
│ │ │ │ │ └ {}
│ │ │ │ └ <Thread(Thread-2, started daemon 140428006546224)>
│ │ │ └ ()
│ │ └ <Thread(Thread-2, started daemon 140428006546224)>
│ └ <bound method IntervalRunner._run of <slack_sdk.socket_mode.interval_runner.IntervalRunner object at 0x7fb7f1a039d0>>
└ <Thread(Thread-2, started daemon 140428006546224)>
File "/usr/local/lib/python3.9/site-packages/slack_sdk/socket_mode/interval_runner.py", line 19, in _run
self.target()
│ └ <bound method SocketModeClient._monitor_current_session of <slack_sdk.socket_mode.builtin.client.SocketModeClient object at 0...
└ <slack_sdk.socket_mode.interval_runner.IntervalRunner object at 0x7fb7f1a039d0>
File "/usr/local/lib/python3.9/site-packages/slack_sdk/socket_mode/builtin/client.py", line 300, in _monitor_current_session
self.connect_to_new_endpoint()
│ └ <function BaseSocketModeClient.connect_to_new_endpoint at 0x7fb7f2e9d8b0>
└ <slack_sdk.socket_mode.builtin.client.SocketModeClient object at 0x7fb7f1aaeb50>
File "/usr/local/lib/python3.9/site-packages/slack_sdk/socket_mode/client.py", line 78, in connect_to_new_endpoint
self.connect()
│ └ <function SocketModeClient.connect at 0x7fb7f2eb0430>
└ <slack_sdk.socket_mode.builtin.client.SocketModeClient object at 0x7fb7f1aaeb50>
File "/usr/local/lib/python3.9/site-packages/slack_sdk/socket_mode/builtin/client.py", line 181, in connect
current_session.connect()
│ └ <function Connection.connect at 0x7fb7f2ea9e50>
└ <slack_sdk.socket_mode.builtin.connection.Connection object at 0x7fb7f12e6910>
> File "/usr/local/lib/python3.9/site-packages/slack_sdk/socket_mode/builtin/connection.py", line 139, in connect
status, headers, text = _parse_handshake_response(sock)
│ └ <ssl.SSLSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.18.0.3', 52092), raddr=(...
└ <function _parse_handshake_response at 0x7fb7f2ea9820>
File "/usr/local/lib/python3.9/site-packages/slack_sdk/socket_mode/builtin/internals.py", line 136, in _parse_handshake_response
line = _read_http_response_line(sock)
│ └ <ssl.SSLSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.18.0.3', 52092), raddr=(...
└ <function _read_http_response_line at 0x7fb7f2ea9790>
File "/usr/local/lib/python3.9/site-packages/slack_sdk/socket_mode/builtin/internals.py", line 115, in _read_http_response_line
c: str = sock.recv(1).decode("utf-8")
│ └ <function SSLSocket.recv at 0x7fb7f4c61b80>
└ <ssl.SSLSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.18.0.3', 52092), raddr=(...
File "/usr/local/lib/python3.9/ssl.py", line 1226, in recv
return self.read(buflen)
│ │ └ 1
│ └ <function SSLSocket.read at 0x7fb7f4c61430>
└ <ssl.SSLSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.18.0.3', 52092), raddr=(...
File "/usr/local/lib/python3.9/ssl.py", line 1101, in read
return self._sslobj.read(len)
│ │ │ └ 1
│ │ └ <method 'read' of '_ssl._SSLSocket' objects>
│ └ <_ssl._SSLSocket object at 0x7fb7f15b9570>
└ <ssl.SSLSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.18.0.3', 52092), raddr=(...
socket.timeout: The read operation timed outCategory (place an x in each of the [ ])
- slack_bolt.App and/or its core components
- slack_bolt.async_app.AsyncApp and/or its core components
- Adapters in slack_bolt.adapter
- Others
Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementM-T: A feature request for new functionalityM-T: A feature request for new functionalitysocket-mode