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

Events are fired twice after a disconnection #362

Closed
ThHareau opened this issue Jan 29, 2021 · 4 comments
Closed

Events are fired twice after a disconnection #362

ThHareau opened this issue Jan 29, 2021 · 4 comments
Labels

Comments

@ThHareau
Copy link

I'm having an issue where my bot is sending several time the same message after a disconnection.

How to reproduce:

Here is a sample of my code:

realtime_client = Slack::RealTime::Client.new token: token,
    websocket_ping: 3 # to fasten the deconnection detection, but not needed to triger the bug

realtime_client.on :hello do
  puts 'Ready to go!'
end

realtime_client.on :message do |message|
  puts 'triggered' if message.text == 'My message'
end

realtime_client.start!

Then, launch the bot, trigger it: one message should happen.

Disconnect your laptop from internet, wait for the warning to come (so that the bot detects the deconnection) and reconnect.
Trigger the bot: it should be triggered twice instead of once.

My logs:

Ready to go!
triggered
W, [2021-01-29T19:01:23.481714 #87339]  WARN -- id=T03L75GUK, name=__, domain=__: is offline
W, [2021-01-29T19:01:24.484552 #87339]  WARN -- id=T03L75GUK, name=__, domain=__: is offline
Ready to go!
triggered
triggered

Hack

Disabling websocket pings fixes the issue:

realtime_client = Slack::RealTime::Client.new token: token, websocket_ping: 0
@dblock
Copy link
Collaborator

dblock commented Jan 29, 2021

What version and async library?

@dblock dblock added the bug? label Jan 29, 2021
@ThHareau
Copy link
Author

Hi, I'm with faye-websocker 0.11.0 and under version 0.15.1

@dblock
Copy link
Collaborator

dblock commented Jan 29, 2021

That's known, dup of #285. We've deprecated faye-websocket in #357, upgrade to 0.16.x with async-websocket and the problem will go away.

@dblock dblock closed this as completed Jan 29, 2021
@ThHareau
Copy link
Author

Oh ok. Thanks!

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

No branches or pull requests

2 participants