Websocket connection to a route
hey guys, need guidance here. Is there an example out there to connect to a route using websocket?
here is my attempt:
the issue is, using websocket trying to connect to ws://localhost:3000/ws/session/test-123 even the GET is not called. So there is not even a chance to upgrade to websocket. Help?
8 Replies
other-emerald•2mo ago
there is no support for websockets yet really in start. probably needs bigger changes
you can leverage nitro though
but it's not a start feature
extended-salmonOP•2mo ago
how does that work? do i need to start a separate service?
other-emerald•2mo ago
best is to search discord, there were some solutions for websockets floating around
right now, the coupling between start and nitro is not optimal w.r.t separations of concerns
we are working on this
eastern-cyan•2mo ago
Correct me if im wrong, but why not using something like partykit, socket.io or pusher for websockets? Unles you really want something skinny those seems to be way more feature complete :p
extended-salmonOP•2mo ago
I searched around and i could not find any solution, there were 2 GitHub links talking about it and one solution that essentially a catch all callback that's not really ideal
Does this introduce a new separate service? Because it's important for the socket connection to live in the same process as the web server due to the latency requirement
metropolitan-bronze•2mo ago
in post de-vinxi tss, ive gotten this to work in dev with a vite plugin that works with the vite dev server, but since tss doesnt expose the nitro configuration for production builds, there is currently no clean way to solve this for prod.
extended-salmonOP•2mo ago
@Joshua this is exactly what i end up doing as well, works in dev but not in prod
optimistic-gold•7d ago
@comfy12345 have you found any ways to get this to work in prod?