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

Reconnect after activity timeout #34

Open
carloquilala opened this issue Dec 10, 2020 · 3 comments
Open

Reconnect after activity timeout #34

carloquilala opened this issue Dec 10, 2020 · 3 comments

Comments

@carloquilala
Copy link

carloquilala commented Dec 10, 2020

Is there a way we can reconnect presence connection?

coz after some time, client stops receiving events

@mayteio
Copy link
Owner

mayteio commented Dec 14, 2020

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?

@carloquilala
Copy link
Author

carloquilala commented Dec 16, 2020

I currently have no sandbox but I'll try to mock the scenario... I'm using JWT to authenticate

  1. user logs in with a token that expires in an hour (token_1)
  2. 5 minutes before the token expires, token will be refreshed to extend the user session (token_2)
  3. 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

@mayteio
Copy link
Owner

mayteio commented Feb 25, 2021

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.

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

No branches or pull requests

2 participants