Forwarding WebSocket messages between Cloudflare Worker instances?

Hi all,

I’ve got a question related to Cloudflare Workers and WebSocket.

Please consider this situation:

  1. worker instance W1 running in some PoP in e.g. Asia has accepted a WebSocket connection incoming from client C1
  2. worker instance W2 running in some PoP in e.g. Europe has accepted a WebSocket connection incoming from client C2
  3. the two WebSocket connections in W1 and W2 are long-lived and kept open by the workers

When receiving a WebSocket message M on C1, is it possible for W1 to forward that message to specifically W2 to send M on C2?

It seems two problems are involved:

  • How does W1 decide to which worker instance W2 the message M needs to be forwarded? Keeping a map in e.g. a Durable Object? How can worker instances be identified?
  • Even if worker instance identification, and decision on which worker instance a message is to be forwarded to can be solved, how would I actually open a connection from W1 to W2 to forward M? Is that even possible without having e.g. a Durable Object in the middle that keeps two connections incoming from W1 and W2, and which can do the forwarding of M?

Thanks a lot for any tips or hints or docs to read!


I’m not sure, but it seem direct Worker-instance to Worker-instance communication is not supported, and what is recommended is always communicating over a Durable Object acting as an intermediate/proxy. Is that correct?