Add connection error/retry API and UI support#2902
Conversation
d49720c to
e4fe5c2
Compare
Signed-off-by: Andrew Stein <steinlink@gmail.com> # Conflicts: # rust/perspective-client/src/rust/lib.rs
d7bcc91 to
53416cc
Compare
Signed-off-by: Andrew Stein <steinlink@gmail.com>
Signed-off-by: Tom Jakubowski <tom@prospective.dev>
a178ccc to
695f4dd
Compare
Signed-off-by: Andrew Stein <steinlink@gmail.com>
695f4dd to
b966a8b
Compare
|
Websockets can only handle auth during handshake. And auth tokens typically have an expiration time for security reasons. If a websocket is open for long enough then the token expires. The currently implemented reconnect function doesn't allow for updating the auth details in the new handshake, which happens at reconnect: it sends the old auth data that was used at the initial handshake. So the new reconnect functionality can't be used for this case: instead, one has to explicitly terminate and clean up the websocket connection and establish a brand new one to handle broken connections properly. I'd suggest to change the reconnect function to enable for an updated URL to reconnect to as a parameter. |
Perspective doesn't handle auth tokens at all. You will need to implement your own |
|
Thanks for the quick response, really appreciate it! And I totally understand that you don't want to expand the scope of perspective with authentication. What I'm seeking is simply not making it impossible. My problem is that this doesn't seem to be a typescript level, client wrapping question, but deeper in how rust handles websocket errors. The client's on_error function adds a non-removable error handler, which seems to keep firing even if one calls .terminate() on the client in typescript and deletes the client object. As I can not use the reconnect function if there is authentication and expired tokens, I have no better idea than instantiating a new client. And what I see that the old on_error keeps firing because of the outdated url. And I also haven't found a way for cleaning up non-used clients, so if I go this route, after a while I see this error in the browser's console: And I don't see how I could workaround that by creating a new websocket client in typescript. I believe it would be the cleanest to support the suggested new url for reconnect: there's no need for a new client for any reasons, so we could simple avoid that, and on_error would also keep working as is now. A much less ideal, but still working solution could be able to remove the on_error handler from typescript, and have a way to delete the client and free up the wasm memory. This way one has to recreate the client in case of an error, refetch all data again, but at least it would work. |
|
We would need to see your implementation, you have quite a lot more going on here well beyond the scope of this (merged, 3mo old) PR. Either way, this PR is not the appropriate venue - please reach out to us at Prospective, or you can open an Issue or Discussion if you have a self-contained, isolated reproduction of a specific issue or behavior you think is broken. |
This PR adds a reconnect API to Perspective, as well as a UX to invoke a reconnect to
<perspective-viewer>.