T
tRPC

❓-help

need help refreshing websocket

Ttwelventi1/26/2024
We currently are using tRPC w/ react and websockets. We’re using the URL of the websocket as the auth token to the websocket I.e. ws://localhost?token=12345 We want to be able to kill this websocket connection and reopen one with a new token, I.e. ws://localhost?token=12346 I’ve tried putting the trpcClient in react state, but when the state updates the old websocket connections stay open. I’ve also tried setting the URL with a function, and manually killing the websocket, and letting the WS automatically reconnect, but there’s no way to manually kill the websocket from the client Does anyone have advice or could like a pattern maybe where the websocket url has to dynamically change. (Or has a better way to continually authenticate a websocket connection)
Ttwelventi1/26/2024
Thanks in advance for any help!!!
BBeBoRE1/29/2024
Pretty sure if you close the websocket connection it will reopen it So you could use that as a side effect when your access code changes
Iitsnotyalc2/21/2024
Following this as I'm having the same issue

Looking for more? Join the community!

Recommended Posts
router is crashing when in separate fileWhen i use router merging and have e.g users router in separate file, i import router from trpc.ts aHow do I pass a Generic to a trpc query procedure?I want to to something like this: ```ts type AppIdsWithConfig = typeof kodixCareAppId | typeof calenIs there something to be done about trpc errors and solidjs/seroval?Basically if you `throw error` in trpc route, solidjs seroval fails to serialize it during SSR. I doHow can i createCaller from a NextJs App Router if my server uses express tRPC adapter?I'm using the express adapter for the server side of tRPC, and the client is a NextJS AppRouter app.Is there a way to refetch a query with new parameters?Hi I'm using tRPC in a Next.js app and I have a button that a user can click to get the latest dataMultiple Routers with WebsocketsHi. I am looking to create two routers with either the same websocket connection or two unique websoIs there any benefit to putting the db connection in the context versus having it as an global var?Can I do this? ```ts export const challengesRouter = router({ getChallengeById: privateProcedure Controller is already closed crashIm using trpc with nextjs 14 app router and started to see that my app crashes due to such error. DiThis page needs to bail out of prerendering at this point because it used revalidate: 0I've been testing out partial prerendering with next using tRPC but having some issues. Everytime How to infer query types on client?```ts export const tenantRouter = router({ getTenants: procedure.query(() => { return { hello:NextJS Output TypingsQuick question probably stupid, I learned about this library yesterday and completely migrated from 'react-server-dom-webpack/client' errorHey, i am trying to get started with TRPC but getting this error ```shell ../../node_modules/.pnpm/