web_socket_client icon indicating copy to clipboard operation
web_socket_client copied to clipboard

feat: a function to generate URI before every connecting

Open laeo opened this issue 2 years ago • 2 comments

Description

I want to add the user authentication token as query param to URI, but the token has short lifetime, while trying reconnect after token expires, there is no way to update the token, it will stuck looping.

WebSocket(
  uri: () => "wss://localhost/?_token=xxxxx", // we can use the callback to retrieve valid token before connects.
);

Requirements

  • [ ] A function to generate URI before every connect happens.

Additional Context

No.

laeo avatar Aug 26 '23 08:08 laeo

This would be helpful for me, are there any suggested alternatives to handle a situation like this?

richiehowelll avatar Jun 13 '24 23:06 richiehowelll

Plus one as I'm also in need of this. In my case the jwt token is sent in the request headers, not the Uri, but the same principle applies - if we could have a way to update the request (Uri / headers etc.) before reconnecting, that would be really helpful.

wkok avatar Aug 25 '24 07:08 wkok