Skip to content
Blog

The streaming failure that returns 200

You point a tunnel at a local model, open the public URL, and ask it something. Nothing happens for eleven seconds. Then the whole answer appears at once.

The obvious reading is that the model is slow. So you check the model, and locally it is fine: tokens land one at a time, the way they should. You check the tunnel, and the tunnel is fine too. Status 200. Content type text/event-stream, exactly as sent. Every byte accounted for, nothing truncated, and no error in the logs you can see.

Everything is fine, and streaming is gone.

Why this one hides

Most tunnel problems announce themselves. A dead tunnel gives you a 502. A blocked port gives you a connection refused. A bad header gives you a 403 with something to search for.

A buffering hop gives you a correct response. It reads your stream to the end, holds it, and hands the whole thing over as one delivery. There is nothing in the status line, the headers or the body to distinguish that from an origin that simply took eleven seconds to answer. The only thing that differs is when the bytes arrive, and nothing you normally look at records arrival times.

So the symptom gets filed against the wrong component. You spend the afternoon on the model.

Measuring it takes about twenty lines

The trick is to make an origin whose timing you already know, then compare. A server that emits five chunks one second apart, flushing each one:

python
import json, time
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
 
class H(BaseHTTPRequestHandler):
    protocol_version = "HTTP/1.1"
 
    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-Type", "text/event-stream")
        self.send_header("Transfer-Encoding", "chunked")
        self.end_headers()
        for i in range(5):
            payload = {"choices": [{"delta": {"content": f"token{i} "}}]}
            data = f"data: {json.dumps(payload)}\n\n".encode()
            self.wfile.write(f"{len(data):X}\r\n".encode() + data + b"\r\n")
            self.wfile.flush()
            time.sleep(1)
        self.wfile.write(b"0\r\n\r\n")
        self.wfile.flush()
 
ThreadingHTTPServer(("127.0.0.1", 8899), H).serve_forever()

Then read the response off the socket and timestamp each line as it lands. The shape of those timestamps is the whole measurement:

  • arrivals about a second apart, the hop streams
  • arrivals all together at the five second mark, the hop buffered the response and released it at the end

Run it against 127.0.0.1 first. That control matters more than it looks: without it, a buffering result could just as easily mean your server never flushed.

What I measured

Measured on 2026-09-22, with cloudflared version 2026.9.1 and the zgrok CLI at 0.15.1, from one laptop, against the same Python origin above, once per shape. The Cloudflare quick tunnel registered at its fra08 edge; the zgrok tunnel terminated at the relay in Nürnberg.

Three response shapes, because the interesting question is not whether one of them breaks but whether the hop treats them differently:

Response bodyCloudflare quick tunnelzgrok
text/event-streamall six lines at +5.51s, spread 0.00sfirst at +0.52s, last at +5.51s
application/x-ndjsonall six lines at +5.45s, spread 0.00sfirst at +0.37s, last at +5.34s
text/plainall six lines at +5.45s, spread 0.00sfirst at +0.46s, last at +5.48s

The localhost control ran at gaps of 1.00s in each of those runs, so the origin was streaming throughout.

Spread of 0.00s is the finding. Not a slow first byte, not a partial stream: the six lines arrived in the same instant, at the moment the origin finished. Through zgrok the same six lines arrived a second apart, with the first one landing before the origin had written the second.

Two explanations I had to rule out first

A measurement that makes a competitor look bad is a measurement to attack, so I went looking for the attacks myself.

Maybe it was my framing. My first version of that server ended the body by closing the connection rather than sending Transfer-Encoding: chunked. A proxy has a legitimate reason to buffer a body delimited that way, because it has to reframe it before forwarding, and then the result would say nothing about streams. So I rewrote the server to send proper chunked encoding, which is what a real SSE endpoint does, and measured again. Identical: spread 0.00s.

Maybe the chunks were too small. Mine were about a hundred bytes. Plenty of proxies pass small writes into a buffer and only start flushing once some threshold is crossed, which would mean a real model response, being much longer, might stream after a slow start. So I padded each chunk to 32 KB, then to 256 KB, making the whole response roughly 1.25 MB. Still spread 0.00s at both sizes. Three points is not a sweep, so I cannot rule out a threshold I did not happen to cross, but a response over a megabyte buffering whole is enough to answer the practical question.

Neither explanation survived. What is left is that this hop buffered the response.

The documentation says less than this

Cloudflare documents a limitation here, and it is worth quoting exactly, because it is narrower than what I saw. Their Quick Tunnels page says quick tunnels "do not support Server-Sent Events (SSE)", alongside a documented ceiling of 200 concurrent in-flight requests and a plain statement that quick tunnels are intended for testing and development rather than production.

Singling out SSE reads like a media type rule: avoid text/event-stream and you are fine. That is not what the numbers say. application/x-ndjson and text/plain buffered exactly the same way, and NDJSON is not a footnote here, it is what Ollama's own /api/chat returns. So switching off the OpenAI-compatible endpoint to dodge the limitation would not have dodged it.

I want to be careful about what that does and does not establish. I measured behaviour from outside, once. I am not claiming to know why it happens, I am not claiming it is permanent, and a product that documents its own limitation is being more honest than most. If you are relying on this, measure it yourself, today, from where you are.

Why zgrok streams, and why that is a decision

The zgrok column above is not luck, and the interesting part is what it cost.

A tunnel server wants a deadline on a backend that has gone quiet, because a wedged origin holding a slot forever is a real problem. The trouble is that a model composing a long answer and a server that has hung look identical from the outside. Both are a connection with nothing arriving on it.

zgrok tried to tell them apart three times, by looking at the response's media type, and each of those releases truncated a real stream. The fix was to stop guessing: the idle deadline now bounds only a write that is parked against the client, and backend silence is deliberately never measured, for any response shape. Hostile slot consumption is bounded by a per-tenant cap instead, which is a control that does not have to be clever about intent.

That is why the table looks the way it does. Not a streaming feature, a classifier we deleted.

If you are tunnelling a local model

Measure before you debug. It is a few minutes, and it tells you which half of the system to look at. Run the twenty line server above behind whatever tunnel you already use, watch the arrival times, and you will know whether the eleven second wait belongs to the model or to the hop in front of it.

If you want the short version for zgrok specifically, Expose a local AI model covers pointing a tunnel at Ollama or LM Studio, and Local AI is the reference.

And if your current tunnel does buffer, that is worth knowing plainly rather than as a mystery. A free account-less tunnel is a genuinely useful thing, and for sharing a page or catching a webhook the buffering does not come up. It comes up the moment the response is supposed to arrive progressively, which is exactly the case a local model is.

Back to blog