wsClient is connecting with server eventhough the splitLink condition is always false #4725
PVSPHANINDRA
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Application Scenario:
I have a server which handles some routes using http and some other with web sockets. I am using the ws package for the socket initialization on the server side.
But from the client side, irrespective of the routes, the web socket connection is called.
So, to make it simple for understanding, I intentionally made the splitLink condition to false.
The below is the the trpc initialization I am making on the client side.
const trpc = createTRPCProxyClient<AppRouter>({ links: [ splitLink({ condition(op) { return false; }, true: wsLink({ client: createWSClient({ // this creates the websocket between the client and server eventhough you dont initiate any request url:ws://localhost:3001, onOpen() { console.log('opened') }, }), }), false: httpLink({ url: "http://localhost:3001", }), }), ], });Yet web socket connection is happening.
Can someone give the best solution to my scenario?
Beta Was this translation helpful? Give feedback.
All reactions