Cloudflare Workers can now accept inbound TCP and gRPC traffic
A public beta lets a Worker take a raw TCP connection through Spectrum, hand it to a Durable Object, and stream it into a gRPC server running in a Container.
Cloudflare put inbound TCP connections to Workers, and bidirectional gRPC in Containers, into public beta yesterday. Until now, Workers could make outbound TCP connections but not accept them, so running your own gRPC server meant putting it behind something other than a Worker.
The new path routes a TCP connection through Spectrum into a Worker, which can forward it to a Durable Object and on to a Container running a gRPC server in any language. The Container handles TLS termination, HTTP/2 and the gRPC processing itself, while the Worker and Durable Object just forward the encrypted bytes, preserving TCP half-closes along the way. Worker-origin Spectrum apps are available on Pro and Business zones, and on Enterprise zones with Spectrum Enterprise turned on; Pro and Business zones without Enterprise get one application per zone on a single TCP port.
Why it matters: this is aimed squarely at real-time services, voice applications are the example Cloudflare gives, that speak raw TCP or gRPC rather than HTTP. Previously that meant running infrastructure outside Cloudflare’s edge just to terminate the connection. Now that can happen in a Worker and Container pair instead.