How to access websocket(Dash extensions) state/status? (Connected,Closed etc.)

Hello Dash Community,

I’d be very grateful if you could provide me with a hint here since I assume it’s not a hard question: In the plotly dash websocket extension documentation it says, that the state of the websocket(Connected,Closed, etc.) is accessible.
My first try was (although it’s not stated in the documentation), that the state might be accessible by a callback:

@app.callback(Output("websocketstate", "children"), Input('ws', 'state'))
def send(state):
    print(state)
    return state

This unfortunately does not fire. I guess I have to rely on a regular Interval if I want to check the status of the websocket, but I still don’t know, how I can then access the “state” property of the component, because afaik, dash components are not accessible directly in Python, only via callbacks.

My second try already was accessing the websocket object with custom javascript, but (also after implementing a reasonable waiting interval till the page is fully loaded), the component specified with e.g.:

app.layout = html.Div(
    [dcc.Location(id="url"), dashsubcomponents.sidebar, content, WebSocket(url="ws://127.0.0.1:5300/", id="ws")])

is not found if I’m trying to access it with:

function regularWebsocketCheck() {
    const plaintextinfo = document.getElementById("websocketstate");
    const websocket = document.getElementById("ws");
    window.setInterval(function () {
        if (websocket.readyState === WebSocket.CLOSED) {
            plaintextinfo.textContent = "Closed"
        }
        if (websocket.readyState === WebSocket.OPEN) {
            plaintextinfo.textContent = "Open"
        }
        if (websocket.readyState === WebSocket.CONNECTING) {
            plaintextinfo.textContent = "Connecting"
        }
    }, 1000);

}

It would be great if you could help me.

Best regards

Daniel