Why AI answers stop halfway: streaming and timeouts
An answer that freezes or arrives all at once is often a connection problem. How streaming works, what cuts it off on the way, and how to find the cause.
3 min read
On this page
The page works, your message was sent, and the answer begins. Then it freezes mid-sentence. Or nothing appears for a minute and the whole answer arrives at once. Both usually come down to one thing that's unusual about AI services: a single response stays open for a long time, with pauses.
If the site doesn't load at all, start with is it down, or is it your network?
How an answer is delivered
A web page arrives in a fraction of a second. An answer is written one token at a time, and sent as it's written, over a connection that stays open. The usual technique is server-sent events: an ordinary HTTP response that doesn't end until the answer does. This is what Claude's API sends:
A normal stream, shortened
event: content_block_delta data: {"type": "content_block_delta", "delta": {"text": "Hello"}} event: ping data: {"type": "ping"} event: message_stop data: {"type": "message_stop"}
An error in the middle of one
event: error
data: {"type": "error", "error": {"type": "overloaded_error", "message": "Overloaded"}}Two things here explain a good deal. Pings exist because a silent connection looks dead to equipment along the way. And because the response began with "200 OK", a later failure can't be reported with a status code. It has to come as an event, or the stream just ends. Your browser's developer tools may show success for an answer that failed.
Some apps use WebSockets for some features. OpenAI's guide for IT departments lists wss://ws.chatgpt.com and says that if WebSocket traffic is blocked, some features may stall, disconnect or fail to stream updates correctly.
Who can cut it off
Everything between you and the service has an opinion about how long a connection may be silent:
Note what nginx's 60 seconds measures: the time between two pieces of data, not the length of the whole response. An answer can stream for ten minutes without trouble, and then a pause of 61 seconds ends it. That's why the problem appears with reasoning models and tools, which can go quiet for a long time before producing text, unless something like a ping fills the gap.
Other things that interrupt:
- Company proxies and security software that inspect traffic. They may wait for a complete response before passing it on, which turns a stream into one long wait. OpenAI's guide asks that TLS inspection not "block, rewrite, or prematurely close" these connections.
- Buffering. nginx's
proxy_bufferingis on by default. Anything that collects data before forwarding makes an answer come in lumps. - Home routers and carrier-grade NAT, which forget connections that have been idle too long.
- Changing networks. Moving from Wi-Fi to mobile data changes your address, and a TCP connection can't move with you.
- VPN reconnects, for the same reason.
- Phones that pause apps in the background.
Not everything is the network
An answer has a maximum length. When it's reached, the text ends mid-sentence, normally with a Continue button. That comes from the service.
Anthropic's documentation says that during periods of high usage an overloaded_error can arrive mid-stream. Check the status page when several answers fail in a short time:
Find the cause
- Is the answer really lost? Reload the page. If the complete answer is there, the service finished and only your connection was cut.
- Try another network, such as mobile data. If it works there, it's something on the first one.
- Turn off a VPN, proxy or security software's HTTPS scanning, one at a time.
- Try a private window to rule out extensions that alter pages.
- Compare a short answer with a long one. If only answers with a long pause fail, suspect a timeout.
From the command line you can see whether streaming works on your network without any AI service. Cloudflare's speed test server can stand in for a long download:
curl -sN -o /dev/null -w '%{http_code} %{time_starttransfer}s %{time_total}s\n' \ 'https://speed.cloudflare.com/__down?bytes=5000000'200 0.458810s 1.686443sIf the time to the first byte is nearly equal to the total, something is holding data back before passing it on. Here the first byte came after 0.46 seconds and the last after 1.69, so data was passed on as it arrived.
If you run the server
For sites that proxy an AI API to their own users: turn off response buffering for those paths, raise the read timeout above your longest pause, send a ping or comment line every 15 to 30 seconds, and handle an error event in the middle of a stream. Anthropic also recommends streaming for long requests, because a connection that waits silently for a complete answer is the easiest to lose.