Skip to content

[BUG] Websocket connection initiated by front end even if not enabled in back end #3939

Closed

Description

@andredfb

Describe your context
Websockt connections are created even if unused.

dash                 4.4.0

Tested in Edge and Firefox.

Describe the bug

I am not sure if this is intended behaviour or a bug. The Dash front end attempts to established a WS connection even if websocket_callbacks=False is set in dash.Dash and no callbacks are set to use websockets.

Expected behavior
It would be preferable that no connection is attempted unless the app is configured to actually use websockets.

Activity

  1. robertclaus commented on Aug 3, 2026

    @robertclaus
    Contributor

    @T4rk1n can you double check this? We should add tests for this if we didn't have them already.

    @andredfb do you have an example app you used to test this?

  2. andredfb commented on Aug 3, 2026

    @andredfb
    Author

    Sorry, I should have specified earlier that I am using the fastapi backend. You can reproduce it with a minimum example:

    from dash import Dash
    from dash import html
    
    app = Dash(
        __name__,
        backend="fastapi",
        websocket_callbacks=False,
    )
    
    app.layout = html.H1("Websocket Test")
    
    if __name__ == "__main__":
        app.run()

    This results in the following in the browser console:
    Image

    And I am able to see the WS connection on the server side logs.

  3. andredfb commented on Aug 3, 2026

    @andredfb
    Author

    As a side note, changing the debug config and the way the uvicorn server is called seems to change exactly how these things are logged in the console too. For example (I am not certain yet what the trigger is), but sometimes the Websocket connected log comes from websocketObserver.ts (webpack://dash_renderer/src/observers/websocketObserver.ts) and other times from the dash renderer.

  4. robertclaus commented on Aug 4, 2026

    @robertclaus
    Contributor

    Thanks @andredfb ! Those details made it easy for @T4rk1n to track down!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2considered for next cyclebugsomething brokensize: 1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions