Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get notification on the front end when the websocket disconnects #2758

Open
0x26res opened this issue Sep 20, 2024 · 1 comment
Open

Get notification on the front end when the websocket disconnects #2758

0x26res opened this issue Sep 20, 2024 · 1 comment

Comments

@0x26res
Copy link

0x26res commented Sep 20, 2024

Feature Request

Description of Problem:

I use perspective for real time dashboard / monitoring, with a python server inspired by the python-tornado-streaming example.

If for whatever reason the browser disconnect from the server, I want to get a notification so I can let the user know that it's disconnected and the information in the dashboard is no longer up to date.

Prior to version 3, I used to do it this way:

                const websocket = perspective.websocket(websocket_uri);
                websocket._ws.onclose = function () {
                    viewer.style.display = "none"
                }

But since version 3, the _ws is no longer available.

Potential Solutions:

Here are some ideas:

  • expose the websocket in the perspective.websocket object, so I can register an onclose callback
  • add an option to clear the grid (or grey out) on disconnect (and on top try to automatically reconnect)

Tasks

No tasks being tracked yet.
@0x26res
Copy link
Author

0x26res commented Nov 4, 2024

As a workaround, I've created a second websocket that connects to the same server and is only used to detect disconnect.

const viewer = document.getElementById("viewer");
const websocket = await perspective.websocket(websocket_uri);
const ws = new WebSocket(websocket_uri);
ws.onclose = function () {
    viewer.style.display = "none"
}

But it'd be better if we could either expose the underlying websocket in the client returned by perspective.websocket, or if we were able to register a callback for disconnection when calling perspective.websocket

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

No branches or pull requests

1 participant