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

Recover messages when on disconnection #315

Open
MarioRuiz opened this issue Mar 24, 2020 · 7 comments
Open

Recover messages when on disconnection #315

MarioRuiz opened this issue Mar 24, 2020 · 7 comments

Comments

@MarioRuiz
Copy link

Add an option to automatically recover messages sent during the time has been auto disconnected from slack.

@dblock
Copy link
Collaborator

dblock commented Mar 24, 2020

You mean build-in retry? What's your scenario? Are we talking RTM or Web API?

@MarioRuiz
Copy link
Author

RTM. Not a retry but to recover the messages we missed during the time was disconnected.
Sometimes the connection is disconnected for a second or a little longer and if we are not lucky and a message was sent during that time, the bot will never respond, even though the connection will be recovered in a second.

@dblock
Copy link
Collaborator

dblock commented Mar 25, 2020

I see. I could be wrong, but I don't think Slack provides that kind of facility.

@dinesh-hd
Copy link

dinesh-hd commented Sep 2, 2020

We could try an exponential backoff, synchronously.
Something like this

number_of_retries = 3
backoff_factor = 2
attempt = 1

First attempt after 2 seconds. [attempt]
Second attempt after 22 (4) seconds. [attempt x backoff_factor]
Third attempt after 4
2(8) seconds. [attempt x backoff_factor]
Finally return result (Success/failure)
The api would return only after all the retries have been completed.

But I don't know if this would be overkill. Considering that the gem returns an error response, the apps using this gem could implement this functionality.

@dblock
Copy link
Collaborator

dblock commented Sep 2, 2020

I think the issue describes recovering incoming RTM messages that were missed, not retrying API calls (that is more standard in client libraries and I'd be open to having that implemented via https://www.rubydoc.info/github/lostisland/faraday/Faraday/Request/Retry).

@MarioRuiz
Copy link
Author

Just to clarify this is the case using the client.on :close, client.on :closed, client.on :hello
[2020-09-28T16:24:08.723056 #17096] INFO -- : Connection closing, exiting. 2020-09-28 16:24:08 +0000
[2020-09-28T16:24:08.723391 #17096] INFO -- : Connection has been disconnected. 2020-09-28 16:24:08 +0000
[2020-09-28T16:24:10.113424 #17096] INFO -- : Successfully connected, welcome 'smart-bot' to the 'xxxxxx' team at https://xxxxxx.slack.com.

So a couple of seconds where the Bot was disconnected, so not listening and if during that time a user sent a message the bot won't be aware of that message and won't respond.
I am facing this kind of disconnections like 10 times every day.
So if we would be aware of the last message received and then on :hello we recover all messages sine last connection we can filter the ones that were sent during the disconnection.

@dblock
Copy link
Collaborator

dblock commented Sep 29, 2020

I don't know of a way to recover those messages :(

This is one of the reasons to switch from an RTM solution to an event-based one (using https://github.com/slack-ruby/slack-ruby-bot-server-events), where Slack will queue messages if your application is not able to respond.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants