question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reduce Number of Reconnection Callbacks on Chat app

See original GitHub issue

Problem

The reconnection callbacks fire frequently as a means of catching up the user when:

  • They move from offline to online
  • They move from active to inactive
  • Laptop is closed and reopened
  • This is a problem because the act of firing all the reconnection callbacks is a very expensive task. There isn’t really any great reason why it should be so expensive and the reasons why should be investigated and fixed. However, this issue is only about reducing how often they run.

To do this we need to stop using the AppState listener and instead use Pusher’s pusher:subscription_succeeded event as mentioned here.

The AppState listener here was added so that we would be able to catch up on missed data when putting the iOS or Android app into the background. Pusher loses connectivity in this case and when it comes back online we aren’t sure if we’ve missed anything so we naively assume that we have and fire the reconnection callbacks.

See relevant code section here

Why is this important?

We should only ask users to “catch up” on data they’ve missed when they need to.

Solution

Reduce number of calls to reconnection callbacks by ditching AppState listener in favor of the Pusher solution linked in the article

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
marcaaroncommented, Jan 15, 2021

Yep, you got it.

2reactions
parasharrajatcommented, Jan 15, 2021

Oh. I see. So you mean we only call the reconnection on one channel for comments on the report and we don’t need to call reconnectionCallbacks for other channels. Nice. 💯

So Now reconnectionCallacks will fire when

  1. When we have connection success on the channel for comments on the report, after
  2. User comes back online (which will be covered in 1).
  3. Computer is back from sleep.

I will prepare a PR and test it thoroughly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reduce Number of Reconnection Callbacks on Chat app #1204
To do this we need to stop using the AppState listener and instead use Pusher's pusher:subscription_succeeded event as mentioned here. The AppState listener ......
Read more >
Best practice for handling connection callbacks inside activity
I am implementing a client in android with retrofit. As i am using asynchronous requests, the client handles every request in a separate...
Read more >
ConnectionHandler - Sendbird Chat
This handler provides callbacks for automatically managed reconnection events. SendbirdChat tries reconnection when the connection is lost.
Read more >
Webhooks (HTTP callbacks): Connection Overrides - Twilio
Twilio uses HTTP callbacks (webhooks) to let your application know when events happen, such as receiving an SMS message or getting an incoming...
Read more >
5 Benefits of Customer Callback - Virtual Hold Technology
Reduce missed customer callbacks by setting text reminders.​​ This improves your reconnect rate and keeps the customer from having to reschedule or call...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found