Skip to content

Fix websocket auth for managed/custom servers behind using bearer-token auth - #2583

Open
jonlamhk wants to merge 1 commit into
Acly:mainfrom
jonlamhk:patch-1
Open

Fix websocket auth for managed/custom servers behind using bearer-token auth#2583
jonlamhk wants to merge 1 commit into
Acly:mainfrom
jonlamhk:patch-1

Conversation

@jonlamhk

@jonlamhk jonlamhk commented Aug 6, 2026

Copy link
Copy Markdown

Problem

Connecting to a ComfyUI server protected by bearer-token
auth (e.g. ComfyUI-Login) in managed or custom-server mode fails at the initial connection:

ServerError: Could not establish websocket connection at ws://...:
server rejected WebSocket connection: HTTP 200

HTTP requests authenticate correctly (Authorization header is set from
settings.server_authorization in init), but the websocket handshake in
connect() is rejected and redirected to the login page, which comes back as
HTTP 200 instead of a 101 upgrade.

Cause

In ComfyClient.connect(), the initial websocket test builds its args from
self._token:

wsargs = websocket_args(self._token)

self._token is only populated for cloud (Interstice) connections, so in
managed/custom mode it is empty and no Authorization header is sent on the
handshake. The ongoing listener in _listen() already uses the correct value
(settings.server_authorization).

Fix

Use settings.server_authorization (falling back to self._token) so the
handshake carries the same bearer token as the HTTP requests and the
listener:

wsargs = websocket_args(settings.server_authorization or self._token)

Tested against liusida/ComfyUI-Login; the connection now upgrades correctly.

…initial websocket connect

Updated websocket connection logic to use token from settings.json server_authorization if available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant