Merge pull request #5270 from cheahjs/fix/websocket-take-2

fix: socket.io connections failing when websockets are not available
This commit is contained in:
Timothy Jaeryang Baek
2024-09-09 23:19:05 +01:00
committed by GitHub
4 changed files with 33 additions and 11 deletions

View File

@@ -2,9 +2,16 @@ import asyncio
import socketio
from open_webui.apps.webui.models.users import Users
from open_webui.env import ENABLE_WEBSOCKET_SUPPORT
from open_webui.utils.utils import decode_token
sio = socketio.AsyncServer(cors_allowed_origins=[], async_mode="asgi")
sio = socketio.AsyncServer(
cors_allowed_origins=[],
async_mode="asgi",
transports=(["polling", "websocket"] if ENABLE_WEBSOCKET_SUPPORT else ["polling"]),
allow_upgrades=ENABLE_WEBSOCKET_SUPPORT,
always_connect=True,
)
app = socketio.ASGIApp(sio, socketio_path="/ws/socket.io")
# Dictionary to maintain the user pool