Websockets with Workers

Howdy y'all! I have a worker that is functioning as a websocket server. Everything works fantastically: - locally / in dev - in production if I use a CLI to interact The second I wire up a browser to it, things start failing though. And what's worse, the failing has almost no details anywhere that I can find. The connection succeeds and then immediately closes. No logs on the backend, and logs on the frontend are code 1006 ("i dunno what happened"). Has anyone seen this before? Any ideas where to dig in? It feels like either browser security (no luck on making CORS permissive) or something strange Cloudflare is doing.
3 Replies
danim47c
danim47c19h ago
Hello, are you using Hono in the worker?
cole
coleOP16h ago
Indeed! I ended up chasing it down - there was some error handling code that was firing at the wrong time and closing the connection in my frontend 😐 Yeah, I want those hours back haha
Avilaa
Avilaa11h ago
bro can you tell me how do i use websockets with workers? or any guide that you used? please

Did you find this page helpful?