wsLink with external (custom) websocket?
I want to integrate an external websocket to tRPC for extra type-safety with wsLink where the url will need to be dynamic and the authentication as well.
The problem is as follows:
1) The websocket url is dynamic. It needs to be requested through an API first to get it, because the system has multiple nodes with different ports.
2) The API response of step 1 includes a authorization token which will need to be send to the connection once connected.
3) After some time the websocket server will send an message with "token expiring" where step 1 will need to take place again to request a new fresh token.
My question is: Does it make sense to integrate such a external websocket into my tRPC client? Is it even possible?
I read the docs put I can't quite put everything together. I know there is a way to make the url a function, but it does not have any params that can be passed? Same goes for the connectionParams?
The only other way I could think of is to make a custom client hook / context provider which takes in the websocket url and authorization, but I would like to integrate it with my existing tRPC client (via splitLink) 🙏
0 Replies