tRPC + WebSocket Client
I have a WebSocket between my backend and an external server. I'm trying to get to this:
I have gone through tRPC's documentation on subscriptions (https://trpc.io/docs/subscriptions) and a few examples, but none seemed to work the way I need it.
I currently have it as a
query
using WebSocket messages cached in a Map
:
Subscriptions / WebSockets | tRPC
Using Subscriptions
8 Replies
I haven’t heard the best things about trpc subscriptions so I haven’t used them. I instead use soketi and pusher js
Theo has an example up with incorporating it here https://github.com/pingdotgg/zapdos
GitHub
GitHub - pingdotgg/zapdos
Contribute to pingdotgg/zapdos development by creating an account on GitHub.
Soketi has kinda loose documentation but their discord is pretty helpful if you need help
Thanks! Are you suggesting I let my backend be a WebSocket Client (to get the data from Server A) and also Server to the users?
I use soketi to proxy from backend to front end
so my backend triggers an event and then my front end consumes it
Its how you would use any managed web socket instance
that zapdos repo is a good example
So what i'm saying is don't use trpc for this, just use the pusher client
Thanks again! Yes, it’s pretty clear now and the documentation is good
I didn’t need true real-time communication (a 1-min delay is fine) but this should be the cleanest way so I don’t end up with a million useless requests
np np!!