mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #20259] [CLOSED] fix: multi-worker direct connection chat streaming timeout #41154
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20259
Author: @Classic298
Created: 12/30/2025
Status: ❌ Closed
Base:
dev← Head:redis-queue📝 Commits (10+)
710003binit8fa83a0Update main.py5a61241Update chat.pya0849d0Update +layout.svelte2cfd08bUpdate main.py44450e8Update main.py3950e22Update main.py296686dUpdate main.py5107f34Update main.py7db6d6cUpdate chat.py📊 Changes
3 files changed (+98 additions, -7 deletions)
View changed files
📝
backend/open_webui/main.py(+14 -0)📝
backend/open_webui/socket/main.py(+69 -0)📝
backend/open_webui/utils/chat.py(+15 -7)📄 Description
Problem
When using direct connection mode with multiple backend workers (uvicorn workers > 1 or multiple k8s pods), streaming chat requests intermittently timeout and never complete.
Root Cause: The generate_direct_chat_completion function dynamically registers a Socket.IO event handler using sio.on(channel, handler) for each streaming request. This handler only exists in the local worker's memory. When the browser's WebSocket connection lives on a different worker, streaming chunks arrive at that worker but no handler exists there - causing messages to be silently dropped and the original request to wait forever.
Solution
Replace per-request dynamic handler registration with a global static handler and Redis pub/sub routing:
Flow After Fix
Files Changed
Testing
Closes #15162
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.