Hello,
I would like to understand the recommended way to combine the client-side getToken callback with the connect/refresh proxy model.
My setup
- This runs in a browser client, and we do not use cookies. The JWT is passed explicitly via the getToken callback, not through a cookie.
- On the client I have a getToken callback that returns a short-lived JWT (valid for ~5 minutes).
- I invoke getToken and pass that token along with the Centrifugo connection request, which goes through a connect proxy.
- My connect proxy backend verifies the token and establishes a server-side subscription.
- When the token is about to expire, the refresh proxy is triggered. However, the refresh proxy only has access to the same token that was sent with the initial connect request, not a freshly issued one.
Question
Is there a way for the client's getToken callback to be re-invoked when the refresh proxy triggers, so the client can supply a newly issued token for the refresh? More generally, what is the recommended pattern for refreshing a client-issued JWT in a connect/refresh proxy setup?
What I currently do (and would like to avoid)
On every refresh event I explicitly expire the connection. This causes a disconnect, and when the SDK attempts to reconnect it invokes getToken again and obtains a fresh token. This works, but the "expire then fully reconnect" cycle feels like unnecessary overhead. I would prefer a pattern that refreshes the token without tearing down the connection.
Environment
- Centrifugo server: v6.7
- centrifuge-js: 5.7.0
- Browser client, no cookies
Thanks in advance for any guidance.
Hello,
I would like to understand the recommended way to combine the client-side getToken callback with the connect/refresh proxy model.
My setup
Question
Is there a way for the client's getToken callback to be re-invoked when the refresh proxy triggers, so the client can supply a newly issued token for the refresh? More generally, what is the recommended pattern for refreshing a client-issued JWT in a connect/refresh proxy setup?
What I currently do (and would like to avoid)
On every refresh event I explicitly expire the connection. This causes a disconnect, and when the SDK attempts to reconnect it invokes getToken again and obtains a fresh token. This works, but the "expire then fully reconnect" cycle feels like unnecessary overhead. I would prefer a pattern that refreshes the token without tearing down the connection.
Environment
Thanks in advance for any guidance.