generative-ai icon indicating copy to clipboard operation
generative-ai copied to clipboard

[Bug]: websocket app demo connection cleanup

Open philhosophy opened this issue 1 year ago • 6 comments

File Name

gemini/multimodal-live-api/websocket-demo-app/backend/main.py

What happened?

closing connections and cleanup

Relevant log output

websockets.exceptions.ConnectionClosedError: received 1011 (internal error) Request trace id: f102afa6f090070d, [ORIGINAL ERROR] generic::resource_exhausted: RESOURCE_EXHAUSTED: Maximum concurrent se; then sent 1011 (internal error) Request trace id: f102afa6f090070d, [ORIGINAL ERROR] generic::resource_exhausted: RESOURCE_EXHAUSTED: Maximum concurrent se

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

philhosophy avatar Dec 24 '24 04:12 philhosophy

Your WebSocket server ran out of resources due to too many connections or insufficient system capacity. The error RESOURCE_EXHAUSTED means the maximum allowed concurrent connections were reached, causing the server to close connections with an internal error.

Fix it by:

Increasing server resource limits. Closing idle or unused WebSocket connections. Adding load balancing for high traffic. Debugging connection cleanup in your backend code.

rajeevrj256 avatar Dec 27 '24 09:12 rajeevrj256

Thank you for the reply and the detailed explanation and proposed solutions. I will look into them.

philhosophy avatar Dec 27 '24 10:12 philhosophy

@philhosophy , did you figure out a way to cleanup connection?

hupili avatar Dec 29 '24 12:12 hupili

+1, the multimodal live api notebook needs connection cleanups to be added- I've hit resources exhausted multiple times.

andrewksmith12 avatar Jan 28 '25 22:01 andrewksmith12

Thanks for the insights!

I also encountered this issue in both the notebook and local demo—refreshing the page multiple times leads to a 1011 (RESOURCE_EXHAUSTED) error, and I have to wait for the API to release resources. I'm still investigating how to properly clean up WebSocket connections. If anyone has suggestions, I'd appreciate the help!

AozakiHayate avatar Jan 29 '25 02:01 AozakiHayate

Anyone suddenly seeing errors like this after it was previously working?

websockets.exceptions.ConnectionClosedError: received 1008 (policy violation) Request trace id: a7eb3fd9f46907a2, Authentication error: 16; Error Details: gbs_data::INVALID_TOKEN: Crypto credential exp; then sent 1008 (policy violation) Request trace id: a7eb3fd9f46907a2, Authentication error: 16; Error Details: gbs_data::INVALID_TOKEN: Crypto credential exp

samlhuillier avatar Feb 18 '25 22:02 samlhuillier