openclaw - 💡(How to fix) Fix [Bug]: agent/embedded ws-stream handshake returns HTTP 500 on 2026.3.28 (falls back to HTTP every turn) [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#57311Fetched 2026-04-08 01:51:11
View on GitHub
Comments
2
Participants
2
Timeline
8
Reactions
0
Timeline (top)
commented ×2labeled ×2closed ×1cross-referenced ×1

agent/embedded WebSocket streaming fails with HTTP 500 on fresh and existing sessions, then falls back to HTTP. Regular gateway/ws traffic for webchat remains healthy at the same time.

Error Message

warn agent/embedded [ws-stream] WebSocket connect failed for session=<new-or-old-session-id>; falling back to HTTP. error=Error: Unexpected server response: 500

Seen repeatedly across multiple session IDs, e.g.: 4a80b376-db9f-41cd-bc13-ee95f34678ba cb216ed7-73b0-43db-8b5f-5fedbaffdfce slug-generator-1774819131410 At same times, gateway ws for UI is healthy: Copy info gateway/ws webchat connected ... client=openclaw-control-ui webchat v2026.3.28 info gateway/ws ⇄ res ✓ chat.history / models.list / node.list / device.pair.list / health

Reproduces after multiple gateway restarts. Reproduces with both old and brand-new sessions. Channel switch to beta did not change behavior because beta currently resolves to same build (2026.3.28).

Root Cause

Reproduces after multiple gateway restarts. Reproduces with both old and brand-new sessions. Channel switch to beta did not change behavior because beta currently resolves to same build (2026.3.28).

Code Example

warn agent/embedded [ws-stream] WebSocket connect failed for session=<new-or-old-session-id>; falling back to HTTP. error=Error: Unexpected server response: 500

Seen repeatedly across multiple session IDs, e.g.:
4a80b376-db9f-41cd-bc13-ee95f34678ba
cb216ed7-73b0-43db-8b5f-5fedbaffdfce
slug-generator-1774819131410
At same times, gateway ws for UI is healthy:
Copy
info gateway/ws webchat connected ... client=openclaw-control-ui webchat v2026.3.28
info gateway/ws ⇄ res ✓ chat.history / models.list / node.list / device.pair.list / health

Reproduces after multiple gateway restarts.
Reproduces with both old and brand-new sessions.
Channel switch to beta did not change behavior because beta currently resolves to same build (2026.3.28).
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

agent/embedded WebSocket streaming fails with HTTP 500 on fresh and existing sessions, then falls back to HTTP. Regular gateway/ws traffic for webchat remains healthy at the same time.

Steps to reproduce

  1. Start/restart gateway (openclaw gateway restart)
  2. Open control UI
  3. Create fresh chat/session
  4. Send ping
  5. Observe logs

Expected behavior

Embedded stream connects over WebSocket normally.

Actual behavior

Embedded stream WS handshake fails with 500; request falls back to HTTP.

OpenClaw version

2026.3.28 (f9b1079)

Operating system

macOS arm64

Install method

npm global

Model

gpt 5.3-codex

Provider / routing chain

openclaw chat or through Telegram

Additional provider/model setup details

No response

Logs, screenshots, and evidence

warn agent/embedded [ws-stream] WebSocket connect failed for session=<new-or-old-session-id>; falling back to HTTP. error=Error: Unexpected server response: 500

Seen repeatedly across multiple session IDs, e.g.:
4a80b376-db9f-41cd-bc13-ee95f34678ba
cb216ed7-73b0-43db-8b5f-5fedbaffdfce
slug-generator-1774819131410
At same times, gateway ws for UI is healthy:
Copy
info gateway/ws webchat connected ... client=openclaw-control-ui webchat v2026.3.28
info gateway/ws ⇄ res ✓ chat.history / models.list / node.list / device.pair.list / health

Reproduces after multiple gateway restarts.
Reproduces with both old and brand-new sessions.
Channel switch to beta did not change behavior because beta currently resolves to same build (2026.3.28).

Impact and severity

No response

Additional information

Functional degradation: every turn falls back to HTTP path. User-visible reliability/perf concern for streaming behavior.

extent analysis

Fix Plan

To resolve the WebSocket streaming issue, we need to update the WebSocket handshake handling in the agent/embedded module.

Here are the steps to fix the issue:

  • Update the ws-stream module to handle HTTP 500 errors during WebSocket handshake.
  • Add retry logic to reconnect to the WebSocket endpoint after a failed handshake.
  • Implement error logging to track and debug WebSocket connection issues.

Example code changes:

// Update ws-stream module to handle HTTP 500 errors
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });

wss.on('connection', (ws) => {
  ws.on('error', (error) => {
    if (error.statusCode === 500) {
      // Retry WebSocket connection after 500 error
      setTimeout(() => {
        ws.connect();
      }, 1000);
    }
  });
});

Verification

To verify the fix, follow these steps:

  • Restart the gateway and open the control UI.
  • Create a fresh chat/session and send a ping.
  • Observe the logs to ensure the WebSocket connection is established successfully.
  • Check for any error messages related to WebSocket connections.

Extra Tips

  • Ensure that the WebSocket endpoint is properly configured and accessible.
  • Monitor the logs for any recurring issues related to WebSocket connections.
  • Consider implementing additional error handling and logging mechanisms to improve debugging and troubleshooting.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Embedded stream connects over WebSocket normally.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING