-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aiohttp based socket_mode failed to reconnect and enter a broken state #1446
Comments
Hi, @woolen-sheep! Thank you for submitting this - I am sorry to hear you're running into some issues 😞 I'd like to get some more information on this issue so I know how to proceed with attempting to replicate - at what point does your app disconnect typically? Have you had any successful reconnections at all (intermittent behavior), or is it just consistently failing to connect each time? |
My App usually kept running for 3-4 days fine and then entered this bad state - so yes, it has been connected and working fine. The reason of receive disconnection is However, in this case, the reason why received disconnect message is NOT important. Please check the Thanks for your quick reply! @hello-ashleyintech |
It's another topic: |
@woolen-sheep thanks for the additional info and for providing such comprehensive info in your original issue! 🙇 It seems like a potential solution here might be to check before this code block whether the However, if it was working successfully and is now causing an exception in the line Let me know if you end up coming across any helpful additional info in the meantime! 🙌 |
It is an aiohttp Exception For the python-slack-sdk/slack_sdk/socket_mode/aiohttp/__init__.py Lines 351 to 386 in ef883ad
By "atomic" I mean: If you update One of the possible solutions here is wrapping this block with If you don't mind, I can try to open a PR to fix this at weekend. |
@woolen-sheep That would be fantastic! Thank you so much - please tag me in the PR once it's ready and I'll be happy to take a look! 🙌 |
Reproducible in:
The Slack SDK version
Python runtime version
OS info
Steps to reproduce:
( All the following are talking about aiohttp based socket_mode
AsyncBaseSocketModeClient
)disconnect
message inrun_message_listeners
run_message_listeners
callsconnect_to_new_endpoint
, meet an Exception at:python-slack-sdk/slack_sdk/socket_mode/aiohttp/__init__.py
Line 367 in ef883ad
Expected result:
The
AsyncBaseSocketModeClient
should handle the Exception correctly and reconnect to slack server successfully.Actual result:
The
AsyncBaseSocketModeClient
failed to reconnect and then entered a broken state that can't be recovered (without restart the process).Explaination of the cause
run_message_listeners
when receives adisconnect
mesage:python-slack-sdk/slack_sdk/socket_mode/async_client.py
Line 142 in ef883ad
SocketModeClient.connect()
, and updatecurrent_session
at:python-slack-sdk/slack_sdk/socket_mode/aiohttp/__init__.py
Line 351 in ef883ad
python-slack-sdk/slack_sdk/socket_mode/aiohttp/__init__.py
Line 367 in ef883ad
If we meet exception here(for example a network issue on host causing the connection closed), it will raise from function
connect()
. At this moment, the new session is already "dead".connect()
before we executeself.monitor_current_session()
at:python-slack-sdk/slack_sdk/socket_mode/aiohttp/__init__.py
Line 372 in ef883ad
so there is no new monitor created.
current_session
:python-slack-sdk/slack_sdk/socket_mode/aiohttp/__init__.py
Lines 150 to 153 in ef883ad
connect_to_new_endpoint
again.AsyncBaseSocketModeClient
will enter a bad state and can't be recovered.The text was updated successfully, but these errors were encountered: