Skip to content

Allow the parent frame of a streamlit app to terminate/restart its websocket #8704

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

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

vdonato
Copy link
Collaborator

@vdonato vdonato commented May 17, 2024

We want to be able to let the parent frame of a streamlit app manage its websocket connection
lifecycle. This PR adds this functionality to our HostCommunicationManager class by adding four
new message types for interacting with a Streamlit app's websocket connection:

  • RESTART_WEBSOCKET_CONNECTION
  • TERMINATE_WEBSOCKET_CONNECTION
  • WEBSOCKET_DISCONNECTED (along with an attemptingToReconnect flag in the message payload)
  • WEBSOCKET_CONNECTED

@vdonato vdonato force-pushed the vdonato/host-websocket-msgs branch 2 times, most recently from 72a5d25 to b43e734 Compare May 21, 2024 23:13
@vdonato vdonato changed the title [WIP] Allow the parent frame of a streamlit app to terminate/restart its websocket Allow the parent frame of a streamlit app to terminate/restart its websocket May 21, 2024
@vdonato vdonato marked this pull request as ready for review May 21, 2024 23:14
@vdonato
Copy link
Collaborator Author

vdonato commented May 21, 2024

Heads up @sfc-gh-pfinnigan @sfc-gh-shaar that these message types should be ready for e2e testing in SiS.

Note the names of the messages are currently:

  • RESTART_WEBSOCKET_CONNECTION
  • TERMINATE_WEBSOCKET_CONNECTION
  • WEBSOCKET_DISCONNECTED (along with an attemptingToReconnect flag in the message payload)
  • WEBSOCKET_CONNECTED

but I'm not very opinionated on these names and am happy to change them if any better one are suggested.

Also, I haven't started looking into websocket close codes or backoffs on ws reconnect retries just yet, but I'll be doing some investigation of those over the next few days.

@vdonato vdonato force-pushed the vdonato/host-websocket-msgs branch from b43e734 to 727dfc9 Compare May 21, 2024 23:27
@vdonato
Copy link
Collaborator Author

vdonato commented May 21, 2024

Temporarily adding the do-not-merge label to this so that we don't actually submit it before some e2e testing is complete

@vdonato vdonato force-pushed the vdonato/host-websocket-msgs branch 5 times, most recently from c5304bb to bb2fcbf Compare June 11, 2024 03:27
@vdonato vdonato force-pushed the vdonato/host-websocket-msgs branch 3 times, most recently from e7ecf74 to aaeabe2 Compare June 11, 2024 04:04
Copy link
Collaborator

@raethlein raethlein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I have left some non-blocking comments. And it'd be sweet to migrate the e2e test soonish to playwright!

Copy link
Collaborator

@mayagbarnes mayagbarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also really appreciate it if you could add these messages to our Host <-> Guest documentation here with some context!

@vdonato vdonato force-pushed the vdonato/host-websocket-msgs branch from aaeabe2 to 96d3e12 Compare June 12, 2024 21:23
@vdonato vdonato force-pushed the vdonato/host-websocket-msgs branch from 96d3e12 to 108093e Compare June 12, 2024 22:13
@vdonato vdonato merged commit b1340be into develop Jun 14, 2024
33 checks passed
@vdonato vdonato deleted the vdonato/host-websocket-msgs branch June 14, 2024 01:49
benjamin-awd pushed a commit to benjamin-awd/streamlit that referenced this pull request Sep 29, 2024
…bsocket (streamlit#8704)

We want to be able to let the parent frame of a streamlit app manage its websocket connection
lifecycle. This PR adds this functionality to our `HostCommunicationManager` class by adding four
new message types for interacting with a Streamlit app's websocket connection:

* `RESTART_WEBSOCKET_CONNECTION`
* `TERMINATE_WEBSOCKET_CONNECTION`
* `WEBSOCKET_DISCONNECTED` (along with an attemptingToReconnect flag in the message payload)
* `WEBSOCKET_CONNECTED`
edegp pushed a commit to edegp/streamlit that referenced this pull request Jan 19, 2025
…bsocket (streamlit#8704)

We want to be able to let the parent frame of a streamlit app manage its websocket connection
lifecycle. This PR adds this functionality to our `HostCommunicationManager` class by adding four
new message types for interacting with a Streamlit app's websocket connection:

* `RESTART_WEBSOCKET_CONNECTION`
* `TERMINATE_WEBSOCKET_CONNECTION`
* `WEBSOCKET_DISCONNECTED` (along with an attemptingToReconnect flag in the message payload)
* `WEBSOCKET_CONNECTED`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants