Replies: 1 comment
-
Thanks! Right now, the only viable option unfortunately is to detect when you need to refresh the token, close down the socket and re-open with the new token. After the re-connection, in order to restart your channels in a way that make sense, you can look at what channels are active by introspecting the However, if you have control over your Phoenix server's handling of the token, you could expose an API on one of the socket's channel where the client can "push" the new token on a live socket and the server just assigns the new token in the socket state in-place. That would avoid the whole reconnection/logic. That's what we do in our project by updating the token before it expires so there's no downtime. |
Beta Was this translation helpful? Give feedback.
-
Hi @matehat,
First of all, I must say that you did a good job with the lib, I love it!
But I have some concerns when it comes to a token refresh logic.
I would like to ask if you could suggest the easiest approach on how to handle this issue?
Right now, my idea is to listen for the errors:
_socket.errorStream.listen((event) {}
I wonder if there is an easier approach?
For example, to just pass a new token to the socket and make it reconnect to the server via that token?
Would it be possible to rejoin channels automatically after that, without need to reinitialise them?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions