[PR #22402] [CLOSED] fix: enable direct connection mode with multiple workers using Redis ... #65515

Closed
opened 2026-05-06 11:22:11 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22402
Author: @Br1an67
Created: 3/8/2026
Status: Closed

Base: mainHead: fix/issue-15162-websocket-worker-routing


📝 Commits (1)

📊 Changes

2 files changed (+92 additions, -14 deletions)

View changed files

📝 backend/open_webui/socket/main.py (+86 -1)
📝 backend/open_webui/utils/chat.py (+6 -13)

📄 Description

Fixes #15162

Summary

Fixed WebSocket/API routing mismatch for direct connection mode with multiple workers by using Redis pub/sub for cross-worker channel communication.

Root Cause

When using "direct connection" mode with multiple workers (workers > 1):
the WebSocket connection and the /api/v1/completions API request may be routed to different worker instances. causing channel events to not reach the handler.

Solution

Use Redis pub/sub for cross-worker communication for channel events:

Changes

  • Added catch-all handler in socket/main.py that publishes channel events to Redis

  • Added subscribe_to_channel() and unsubscribe_from_channel() functions for channel subscription management

  • Modified generate_direct_chat_completion() to use the new channel subscription mechanism instead of local sio.on() handler

  • Falls back to local handling when Redis is not available

Testing

Tested with 8 workers using Redis as the WebSocket manager (as per issue config)

  • Verified that channel events are properly routed across workers
  • Confirmed no regression for single-worker deployments (Redis disabled)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22402 **Author:** [@Br1an67](https://github.com/Br1an67) **Created:** 3/8/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/issue-15162-websocket-worker-routing` --- ### 📝 Commits (1) - [`f29fd2d`](https://github.com/open-webui/open-webui/commit/f29fd2db8dc6ea9b4c3ee42852f666c12d79e006) Merge pull request #22168 from open-webui/dev ### 📊 Changes **2 files changed** (+92 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/socket/main.py` (+86 -1) 📝 `backend/open_webui/utils/chat.py` (+6 -13) </details> ### 📄 Description Fixes #15162 ## Summary Fixed WebSocket/API routing mismatch for direct connection mode with multiple workers by using Redis pub/sub for cross-worker channel communication. ## Root Cause When using "direct connection" mode with multiple workers (workers > 1): the WebSocket connection and the `/api/v1/completions` API request may be routed to different worker instances. causing channel events to not reach the handler. ## Solution Use Redis pub/sub for cross-worker communication for channel events: ### Changes - Added catch-all handler in `socket/main.py` that publishes channel events to Redis - Added `subscribe_to_channel()` and `unsubscribe_from_channel()` functions for channel subscription management - Modified `generate_direct_chat_completion()` to use the new channel subscription mechanism instead of local `sio.on()` handler - Falls back to local handling when Redis is not available ## Testing Tested with 8 workers using Redis as the WebSocket manager (as per issue config) - Verified that channel events are properly routed across workers - Confirmed no regression for single-worker deployments (Redis disabled) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 11:22:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#65515