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

Always send subscribe request when connecting to streaming #14579

Closed
wants to merge 1 commit into from

Conversation

zunda
Copy link
Contributor

@zunda zunda commented Aug 17, 2020

I noticed my browser stops receiving notifications after the streaming server restarts. This change makes the browser to send subscribe request every time after the WebSocket is reconnected so that the browser keeps receiving notifications when the streaming server comes back.

Needed for reconnection to streaming after restart of streaming server.
@ClearlyClaire
Copy link
Contributor

Hm, wouldn't that incorrectly bump the number of subscriptions from each channel at each reconnect?

@zunda
Copy link
Contributor Author

zunda commented Aug 17, 2020

Not on the client side. The server may see extra subscription requests. I naively assumed it is idempotent on the server side.

@ClearlyClaire
Copy link
Contributor

It is, but as far as I understand the issue, subscriptionCounters are incremented at the first subscription, not decremented on disconnect, and the codepath for reconnect goes through the same code (checking if there's already a subscription, and incrementing the counter).

I meant, your change does fix the client not reconnecting, but as far as I understand, the refcounting remains broken in such a way that the count doesn't correspond to active subscriptions anymore, and unsubscribing from the rest of the UI codebase won't actually unsubscribe from the server because of it.

@zunda
Copy link
Contributor Author

zunda commented Aug 17, 2020

Got it! Honestly, I didn't fully understand the logic behind the counter and I tried to avoid touching it...

zunda added a commit to zunda/mastodon that referenced this pull request Aug 20, 2020
Before this change:
- unsubscribe() was not called for a disconnection
- subscriptionCounters were incremented twice for a single reconnection,
  first from connected() and second from reconnected()

This might be a better solution than
mastodon#14579
to recover subscriptions after a reconnect.
zunda added a commit to zunda/mastodon that referenced this pull request Aug 20, 2020
Before this change:
- unsubscribe() was not called for a disconnection
- It seems that WebSocketClient calls connected() and reconnected().
  subscriptionCounters were incremented twice for a single reconnection,
  first from connected() and second from reconnected()

This might be a an additional change to
mastodon#14579
to recover subscriptions after a reconnect.
Gargron pushed a commit that referenced this pull request Aug 24, 2020
Before this change:
- unsubscribe() was not called for a disconnection
- It seems that WebSocketClient calls connected() and reconnected().
  subscriptionCounters were incremented twice for a single reconnection,
  first from connected() and second from reconnected()

This might be a an additional change to
#14579
to recover subscriptions after a reconnect.
@Gargron
Copy link
Member

Gargron commented Aug 24, 2020

Is this still needed after #14608?

@ClearlyClaire
Copy link
Contributor

It can't hurt, but I don't believe it is needed.

@zunda
Copy link
Contributor Author

zunda commented Aug 24, 2020

The original problem is fixed with #14608. This may still be good to have as the code is more resilient to inconsistent counts. On the other hand, this might hide the direct cause of a problem we may discover later.

@Gargron Gargron closed this Aug 24, 2020
thenameisnigel-old pushed a commit to ChatterlyOSE/Chatterly that referenced this pull request Sep 6, 2020
Before this change:
- unsubscribe() was not called for a disconnection
- It seems that WebSocketClient calls connected() and reconnected().
  subscriptionCounters were incremented twice for a single reconnection,
  first from connected() and second from reconnected()

This might be a an additional change to
mastodon#14579
to recover subscriptions after a reconnect.
thenameisnigel-old pushed a commit to ChatterlyOSE/Chatterly that referenced this pull request Sep 7, 2020
Before this change:
- unsubscribe() was not called for a disconnection
- It seems that WebSocketClient calls connected() and reconnected().
  subscriptionCounters were incremented twice for a single reconnection,
  first from connected() and second from reconnected()

This might be a an additional change to
mastodon#14579
to recover subscriptions after a reconnect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants