Fix: LM Studio "Client Disconnected" Errors When Using Slow Local Models
If you're running OpenClaw with LM Studio and your local models take a long time for prompt processing (10+ minutes is common with large models on CPU), you might encounter the dreaded "Client disconnected" error in your LM Studio logs—even though your model is still thinking.
This guide explains the two timeout layers you need to configure and how to fix them.
The Problem
A community member shared this exact issue in Discord:
I'm using OpenClaw with LM Studio and the LLM often takes like 25 minutes for prompt processing. But OpenClaw has a timeout that doesn't wait for LM Studio because the log shows:
[LM STUDIO SERVER] Client disconnected.I already have
agents.defaults.timeoutSeconds: 3600in my config. Can I make OpenClaw wait longer?
Why timeoutSeconds Alone Isn't Enough
Here's the key insight: OpenClaw has two separate timeout layers, and most people only configure one.
Layer 1: Agent Timeout
agents:
defaults:
timeoutSeconds: 3600 # 1 hourThis controls how long an agent run can last. If you set this to 3600 seconds, your agent won't be killed for running too long. But this doesn't control HTTP connection timeouts.
Layer 2: HTTP Client Timeout
When LM Studio is doing prompt processing, it's not sending any data back to OpenClaw. The HTTP connection just sits there, waiting. Node.js's HTTP client (undici) has its own timeouts:
- Headers Timeout: How long to wait for the response headers
- Body Timeout: How long to wait between chunks of data
If your model takes 25 minutes to start responding, you'll see errors like:
UND_ERR_HEADERS_TIMEOUTHeadersTimeoutErrorUND_ERR_BODY_TIMEOUT
The Fix
You need to increase the HTTP-level timeouts. Add this to your OpenClaw config:
http:
bodyTimeout: 3600000 # 1 hour in milliseconds
headersTimeout: 3600000 # 1 hour in millisecondsComplete Config Example
Here's a full config snippet for LM Studio users with slow models:
agents:
defaults:
timeoutSeconds: 7200 # 2 hours for the agent run
http:
bodyTimeout: 3600000 # 1 hour HTTP body timeout
headersTimeout: 3600000 # 1 hour HTTP headers timeoutHow to Apply the Changes
- Edit your config:
openclaw config edit - Add the
httpsection with the timeout values - Restart your gateway (config changes don't apply until restart):
openclaw gateway restart - Verify the config loaded correctly:
openclaw config get http.bodyTimeout
Debugging Tips
If you're still having issues, check the logs right when the disconnect happens:
openclaw logs --followLook for:
embedded run timeout … timeoutMs=…→ Agent timeout (increasetimeoutSeconds)UND_ERR_HEADERS_TIMEOUT→ HTTP timeout (increasehttp.headersTimeout)UND_ERR_BODY_TIMEOUT→ HTTP timeout (increasehttp.bodyTimeout)
Alternative: Streaming Keepalives
Some LLM servers support sending keepalive chunks during long processing phases. If LM Studio supports this option, enabling it can prevent timeout issues without needing massive timeout values. Check your LM Studio settings for streaming or keepalive options.
Sourced from a help thread in the OpenClaw Discord. Thanks to 7underlines for reporting and Krill for the detailed debugging!
Comments (0)
No comments yet. Be the first to comment!