Websockets, Durable Objects & Subrequest Limits

Hey folks, I'm trying to design an application on Workers that involves long-lived Websockets. I want to proxy the websocket to another service (hosted off of CF) and I want to forward a copy of all the messages that go over the socket a Queue. I have this working, but I run into subrequests limits with the Queue writes. After 1k message have been sent over the socket, we need to tear-down and re-establish the session be able to keep writing to the queue. I'm thinking it may be possible to forward to the messages to a Durable Object (over a single websocket) and publish to the queue from there, but I'm not sure what subrequest limits would apply in this case. Any idea if this would work? Or if there's another way of going about this?
1 Reply
xintercept
xintercept7mo ago
This is the solution I came up with, seems to be be working so far: * Worker terminates client websocket * Worker connects to Durable Object via websocket * Messages are sent through to the Durable Object * Durable Object writes these to storage, and schedules an alarm * On alarm, flush the contents of the storage to the queue
Want results from more Discord servers?
Add your server