Pusher doesn't receive events after reconnect
Asked Answered
P

1

1

I am building browser application with real-time updates.

Application allows to read and edit spreadsheet together with other people online.

However, some people have poor Internet connection and disconnects may occur.

I want application to be able to update to the latest data after Internet reconnection.

Currently Pusher and application work so:

  1. Pusher connects to server and receives events.
  2. Other people make changes in spreadsheet.
  3. Application receives these changes from Pusher and is able to reflect them on spreadsheet.
  4. At some moment Internet disappears.
  5. Pusher detects this and automatically tries to reconnect.
  6. Other people make changes in spreadsheet.
  7. Application can't receive these changes because there is not Internet connection.
  8. After some time, for example 5 minutes, Internet connection seems to be ok.
  9. Now Pusher successfully reconnects to server.
  10. However, Pusher doesn't receives events from period when there was no Internet connection (list item #6).
  11. Other people make changes.
  12. Pusher receives events and application is able to handle them.

So my problem is: Pusher doesn't receive events after automatic reconnect which were triggered by other people during Internet disconnection.

I am using default Pusher configuration, private channel, latest stable version and don't do any magic.

Petrous answered 7/2, 2017 at 18:26 Comment(0)
P
4

Pusher does not currently provide this functionality. To implement this yourself you would have to send a numeric ID with each message that increases in value. You would also need to store a cache of all sent messages in a database. Clients can keep track of the last ID they received. After disconnecting and reconnecting, they can send a request to your server asking for all messages greater than the last message ID they received. Your server should respond with messages matching that query in your database.

Powerdive answered 8/2, 2017 at 9:53 Comment(3)
Currently I have such implementation but without Pusher using plain HTTP requests. In general it checks new events every 2 seconds and stores last received event ID. However this works slow so I decided switch to Pusher.Petrous
I'm disappointed in Pusher. This behaviour isn't described in docs.Petrous
Thank you, Will Sewell. I will mark your answer as accepted and will try to find alternative to Pusher or leave my realtime module as is.Petrous

© 2022 - 2024 — McMap. All rights reserved.