Socket Mode: ENOTSOCK every 300 minutes on Windows
See original GitHub issueEdit: updated reproducible versions to latest.
Functionality is not impacted; the reconnect happens properly. This bug is about log spam.
Reproducible in:
slack-sdk-3.7.0 slack-bolt-1.6.1 Python 3.7.8 MINGW64_NT-10.0-18363 Microsoft Windows [Version 10.0.18363.1621]
Steps to reproduce:
app = slack_bolt.App(token=<OAUTH_TOKEN>, signing_secret=<SIGN_SECRET>, logger=...)
handler = slack_bolt.adapter.socket_mode.SocketModeHandler(app, <APP_TOKEN>)
Run, then wait 300 minutes.
Actual result:
Every 300 minutes, this error is logged.
2021-07-06 18:53:32,090 S.Sok ERROR on_error invoked (session id: 2585b6bb-07ea-470e-be5c-449bf120f013, error: OSError, message: [WinError 10038] An operation was attempted on something that is not a socket)
Traceback (most recent call last):
File "...\slack_sdk\socket_mode\builtin\connection.py", line 289, in run_until_completion
all_message_trace_enabled=self.all_message_trace_enabled,
File "...\slack_sdk\socket_mode\builtin\internals.py", line 235, in _receive_messages
logger=logger,
File "...\slack_sdk\socket_mode\builtin\internals.py", line 251, in _fetch_messages
remaining_bytes = receive()
File "...\slack_sdk\socket_mode\builtin\internals.py", line 226, in receive
raise e
File "...\slack_sdk\socket_mode\builtin\internals.py", line 217, in receive
received_bytes = sock.recv(size)
File "C:\python3\lib\ssl.py", line 1058, in recv
return super().recv(buflen, flags)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
Analysis
10038 is WSAENOTSOCK
and (in Python on Windows) also errno.ENOTSOCK
. It’s roughly comparable to EBADF
(see for example https://bugs.python.org/issue13344) Should it be caught in _fetch_messages
?
except OSError as e:
if e.errno == errno.EBADF: # if e.errno in (errno.EBADF, errno.ENOTSOCK)
logger.debug("The connection seems to be already closed.")
return bytes()
Other info
Every now and then (~25% of the time?) this error is logged immediately afterwards.
2021-07-06 18:53:35,412 S.Sok ERROR Failed to establish a connection (session id: f1c1ee8e-a386-4e8a-8bd4-81b911c4a813, error: The read operation timed out)
Traceback (most recent call last):
File "...\slack_sdk\socket_mode\builtin\connection.py", line 139, in connect
status, headers, text = _parse_handshake_response(sock)
File "...\slack_sdk\socket_mode\builtin\internals.py", line 150, in _parse_handshake_response
line = _read_http_response_line(sock)
File "...\slack_sdk\socket_mode\builtin\internals.py", line 129, in _read_http_response_line
c: str = sock.recv(1).decode("utf-8")
File "C:\python3\lib\ssl.py", line 1056, in recv
return self.read(buflen)
File "C:\python3\lib\ssl.py", line 931, in read
return self._sslobj.read(len)
socket.timeout: The read operation timed out
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Intro to Socket Mode - Slack API
In Socket Mode, your app still uses the very same Events API and interactive components of the Slack platform. The only difference is...
Read more >MCP Sockets Service Programming Guide - Bitsavers.org
The only warranties made by Unisys, if any, with respect to the ... ENotSock. (Н59). The socket parameter is not a valid socket...
Read more >c-run-time-reference.pdf
The Microsoft run-time library provides routines for programming for the Microsoft Windows operating system. These routines automate many common programming ...
Read more >UNIX socket error : socket operation on non-socket
I really don't see where it comes from, because my server is very similar and I don't have any problem. My server is...
Read more >VSI TCP/IP Services for OpenVMS Sockets API and System ...
Each step in the Sockets communications process has a corresponding ... When writing network applications, the developer uses the mode of communication.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @dubois, we’ve just released v3.9.0rc2, which includes the fix for this issue. If you have a chance, try the version out 👋 https://pypi.org/project/slack-sdk/3.9.0rc2/
@dubois Thanks for taking the time to try the RC1 version! And, I’m sorry for bothering you as the updates on the WebClient does not help you resolve the issue described here.
Also, the analysis in your description looks valid. I will come up with updates on the relevant part and will release a new RC version including the change. Thanks for being patient and helping us resolve the issue.