Comments (6)
It's another topic:
I think the SDK needs to call disconnect()
explicitly when receive a disconnect
message because it seem the slack server side didn't cut off the old connection... I am not very sure about this. I might do some tests and open another issue to talk about that.
from python-slack-sdk.
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?
from python-slack-sdk.
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 too_many_websockets
: The SDK will auto renew the session every 5 hours (actually this is requested by the slack server backend) but it didn't call disconnect()
explicitly so the connection_num
will keep growing and finally reache the limitation of slcak (max 10 connections). This should be fine because I am only using the latest renewed one, all other connections are staled.
However, in this case, the reason why received disconnect message is NOT important. Please check the Explaination of the cause
section of my issue. I think it's a logical corner case of slack SDK that rarely happens.
Thanks for your quick reply! @hello-ashleyintech
from python-slack-sdk.
@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 current_session
is currently active and running before comparing it to the session
and then implement some sort of retry to attempt to recreate a successful connection for current_session
, and then cancel out after a certain amount of failed retry attempts. What do you think?
However, if it was working successfully and is now causing an exception in the line await self.current_session.ping(f"sdk-ping-pong:{t}")
, I do wonder if it's also something on the aiohttp
side that is causing it to suddenly start failing to reconnect. I will do some more digging to see if there are any recent updates or issues or anything that may have caused this on that end. If it is an aiohttp
side issue, then the above retry will likely not be a good solution to move forward with since it will continue to consistent fail even with that implemented.
Let me know if you end up coming across any helpful additional info in the meantime! 🙌
from python-slack-sdk.
It is an aiohttp Exception ConnectionResetError
but I think it's not a continuous issue because if I restart the process it can back to normal immediately. So it's more like something caused by network issue within a very short period.
For the slack-sdk
side, we don't need to care about the Exception type when consider the logic. The root issue is that: The following code block should be kind of "atomic":
python-slack-sdk/slack_sdk/socket_mode/aiohttp/__init__.py
Lines 351 to 386 in ef883ad
By "atomic" I mean: If you update self.current_session
to a new session, you MUST ensure a new monitor_current_session()
and a new receive_messages()
start to run.
One of the possible solutions here is wrapping this block with try ... catch
and then retry connect when Exception happens.
If you don't mind, I can try to open a PR to fix this at weekend.
from python-slack-sdk.
@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! 🙌
from python-slack-sdk.
Related Issues (20)
- files_upload() initial_comment isn't formatted (regression) when posting a Slack post HOT 5
- Download file using WebClient HOT 1
- Add MongoDB installation store HOT 2
- Happy Holidays! ❄️ ⏳ The team will be on break from Dec 22nd 2023 to Jan 3rd 2024
- Built-in InstallationStores fail to resolve a valid bot token when both bot and user-only installations co-exist in database tables HOT 2
- block/type/image should allow image_url to reference an uploaded file to Slack without having to make it public HOT 2
- Add "slack_file" properties to "image" blocks/elements under slack_sdk.models
- Option to block link url preview HOT 1
- Append `thread_ts` to the payload of a lazy listener in Slash Commands HOT 2
- What is 'Received a response in a non-JSON format' in chat.update HOT 3
- Can't install async (optional) dependencies in 3.26.2 HOT 1
- VSCode (with jedi) can't suggest imports beyond base level of package HOT 5
- [error ] Failed to receive or enqueue a message: TypeError, object of type 'NoneType' has no len() HOT 1
- I am trying to post a message to slack along with a attachment i am getting error as The server responded with: {'ok': False, 'error': 'channel_not_found'} HOT 4
- Unpredictable behaviour using .files_upload_v2 HOT 3
- websocket_client-based SocketModeClient does not reconnect after a DNS outage HOT 1
- ModuleNotFoundError: no module named 'slack' HOT 14
- client.files_upload_v2 complains about channel not found but client.files_upload works. HOT 3
- `RichTextElement.elements` items are never promoted to a proper Python object type HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-slack-sdk.