K8 - Error during WebSocket handshake: Unexpected response code: 200

Hi @alee

Can you give a little more information about your Kubernetes setup? Or, even better: can you provide steps to reproduce your setup? (if possible!)

I havenā€™t seen those error messages before, but I believe theyā€™re coming from somewhere in your k8s infrastructure. Itā€™s hard to tell without knowing your exact setup but my guess is that somewhere in your settings you need to open access to these 3 endpoints: /healthz, /stream, and /message.


Ok, nerd time :nerd_face:. In case youā€™re curious about what those endpoints do, hereā€™s a quick description:

Streamlit apps need to access to a few different routes in the Streamlit server. Most data between the server and the app is communicated via a websocket connection at the /stream endpoint. But before the websocket connection is established (and also any time it goes down), the app continuously pings the server at /healthz to see if should try to reconnect the websocket.

Thereā€™s also another endpoint at /message which is used to cache messages sent back and forth between the server and the app. Iā€™m not going to go into much detail about what this does, but the high level bit is that it improves Streamlitā€™s performance.

This is all probably TMI, but I thought you (or others!) may be curious about why these endpoints exist :smiley:

And just because I spend 5 minutes doing some ASCII art, hereā€™s a diagram of the whole thing:

(Terminal)                                       (Browser)

+------------------+                             +------------------+
| Strealmit server |                             | Streamlit app    |
|                  |                             |                  |
| Routes:          |                             |                  |
| /                |<- HTML/JS/CSS assets -------|                  |
| /healthz         |<- Server "is-alive" check --|                  |
| /stream          |<- Websocket connection -----|                  |
| /message         |<- Packet cache -------------|                  |
|                  |                             |                  |
+------------------+                             +------------------+
2 Likes