Reconnect after activity timeout
Is there a way we can reconnect presence connection?
coz after some time, client stops receiving events
It shouldn't do that, the whole point of websockets is that it's a long running connection. We're using it for connections that run overnight. Do you have a code sandbox you can send that I can look at?
I currently have no sandbox but I'll try to mock the scenario... I'm using JWT to authenticate
- user logs in with a token that expires in an hour (token_1)
- 5 minutes before the token expires, token will be refreshed to extend the user session (token_2)
- PusherProvider still uses auth header authorization bearer (token_1) but is now invalid when trying to authenticate again (subscribing to a new channel)
what I've tried
when the system calls an api to refresh, in my saga, I put first a null token, then put next a new token
problem is it renders twice, without PusherProvider and with PusherProvider so that it can authenticate with the new token (token_2)
UPDATE
please take a look of this example codesandbox... please take a look at the request header "Authorization" property
https://codesandbox.io/s/dazzling-haibt-06kbj
Hmmm, I see. The user only needs a pusher auth token once though - then the connection can stay live as long as they are active. Is the issue if, I.e. they lose wifi and reconnect, it has to get a new token because the old one might be stale?
I can’t really think of a simple way to fix this with authEndpoint. An authorizer might work better here.