Pusher doesn't receive events after reconnect

浪尽此生 提交于 2019-12-24 09:25:15

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/42097246/pusher-doesnt-receive-events-after-reconnect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!