Cannot get subscription event to fire
Ripping my hair out here trying to get Websockets working with tRPC and Next. Everything seems to be working and the frontend client is connecting to my websocket server, however triggering the addFact mutation does not not successfully emit the new catFact despite there not being any errors. I've looked at various repos that achieve similar functionality and haven't been able to spot the problem, does anyone have any guidance?
2 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Thank you very much for the detailed response! The issue turned out to be caused by Next.js using different processes and therefor contexts between the two endpoints, I was using an EventEmitter to trigger the webhooks but each context had it's own isolated EventEmitter. Ended up switching to Redis to solve the issue 🤦♀️
I also struggled with setting up redis. My current working example is much the result of brute force trial / error:
hope this helps!
I just used the redis npm package
that's great though
Ya I'm not sure how performant that is, but it seemed to be the only way I could get it to work when I was fiddling around
np, and good luck!