This is my infrastructure for these apps:
GCE Global LB (central GCP project) => Internet NEG => Cloud run app (streamlit app in its own project)
I have seen a lot of stuff online about users having issues running streamlit apps on cloud run related to websockets, but the app runs fine if accessed directly.
The app runs fine in the following cases:
- If you access it directly through the cloud run URL ie
https://myapp-abc123-uc.a.run.app
- If I create a GCE LB in the same project and hook it up to the cloud run app with a serverless backend
My GCE LB is in a central project and I want to route traffic to cloud run apps in other projects. This can be done via internet negs that route to the cloud run app URL (and set a header), this article explains the setup: https://medium.com/google-cloud/cloud-run-and-load-balancing-go-beyond-your-own-project-adfa1c8b001d
That all works traffic routing wise, but the streamlit app throws errors like this when I try to access it via the load balancer: WebSocket connection to 'wss://my.domain.com/my_app/_stcore/stream' failed:
.
The LB routing looks like: Path "/my_app" in URL map
=> backend with request header of "host: myapp-abc123-uc.a.run.app"
=> internet neg with fqdn of "run.app"
I suspect it might be because, while GCE LBs support websockets ootb, my routing to the URL directly is breaking the connection?
Is there a way I can fix these websocket errors? Do I need to make code changes to support this config or do I need to explicitly pass around headers or something?