Skip to content
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

can I have multiple sockets connection with one app #448

Closed
jgengo opened this issue Aug 25, 2021 · 5 comments
Closed

can I have multiple sockets connection with one app #448

jgengo opened this issue Aug 25, 2021 · 5 comments
Labels
question Further information is requested

Comments

@jgengo
Copy link

jgengo commented Aug 25, 2021

Hello 👋🏻

I read the Slack documentation regarding the Socket and it seems to says that it can works up to 10 simultaneous socket per app.

I tried today, and it acts quite weirdly, it seems that I receive some of the events, but not all of them. It might dispatch one to my first slack-bolt socket and not the other one, and the other way around some time.

Do you know if there is something that could be preventing slack-bolt to work with simultaneous connection with the same app?

I would like if possible to receive the events to all the listening sockets.

Thanks

@jgengo jgengo changed the title (Set a clear title describing your question) can I have multiple sockets connection with one app Aug 25, 2021
@mwbrooks mwbrooks added the question Further information is requested label Aug 25, 2021
@mwbrooks
Copy link
Member

Hey @jgengo 👋🏻

Unfortunately, the behaviour described is expected. When multiple instances of the app each establish the same SocketMode connection, then the Slack API server will send each event to only 1 random connection.

If you need to scale to multiple app instances, then you may need to use 1 app that establishes a SocketMode connection and adds each request to a job queue for other instances to handle. We don't have a working example of this but if you want to share your solution then we'd greatly appreciate it!

@jgengo
Copy link
Author

jgengo commented Aug 25, 2021

@mwbrooks thank you for your response.

I might come up with something.

I could defo propose a solution with a rabbitmq, but I'm quite short on time. I might come back with a solution at some point.

Where do you want me to propose my solution? in this issue?

@seratch
Copy link
Member

seratch commented Aug 26, 2021

Hi @jgengo, if you implement some solution for your use case, as @mwbrooks suggested, doing as below should work for you.

  • A single WebSocket connection must receive all incoming requests from Slack and relay them to a job queue. For this app, you can use the underlying SocketModeClient rather than bolt-python. Directly handling the WebSocket messages can simplify the code. Refer to the document and the examples in the repo.
  • As for other instances, you can use bolt-python but you need to implement your own adapter (document), which communicates with the job queue properly.
  • If your app supports interactivity such as modal data submission, acknowledging the request must be done by only one app instance. Sending acknowledgement multiple times does not work (only the first one will be accepted by the Slack server-side). For this reason, only for synchronous interactivity handling (imagine ack(errors) in modal submission listeners), you may want to skip using the job queue. A possible solution would be to have an instance that is dedicated to the interactivity requests. The SocketMode client relays those requests to the instance directly.

Where do you want me to propose my solution? in this issue?

At least in the short term, we (as bolt-python maintainers) are not planning to add any built-in functionalities for this use case. Thus, from bolt-python project maintenance perspective, I'm leaning toward closing this issue. But, once you share your work as your own GitHub project in the future, sharing the URL here would be greatly appreciated!

@jgengo
Copy link
Author

jgengo commented Aug 26, 2021

@seratch alright! noted!

Thank you

@seratch
Copy link
Member

seratch commented Aug 28, 2021

Thus, from bolt-python project maintenance perspective, I'm leaning toward closing this issue.

For this reason, let us close this issue. Thanks for starting this conversation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants