You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The python gradio_client library does not cache any server cookies unless the Client constructor is called with password authentication via auth argument. (You can see this by inspecting the code: The Client.cookies member is only set in one place, on this line, inside the _login method.)
However, cookies are not only used for authentication. They are also needed in other scenarios - such as, properly routing requests when using multiple replicas of a service in Kubernetes. (The documentation mentions using sessionAffinity, but this doesn't work with ingress, as explained here.)
Have you searched existing issues? 🔎
I have searched and found no existing issues
Reproduction
This bug is reproducible with any demo running in multiple replicas in Kubernetes, when called using the client API. But it's a bit tricky to provide a minimal example here, because it would include docker containers, k8s yamls and all kinds of other things that have nothing to do with gradio.
Screenshot
No response
Logs
No response
System Info
I've reproduced this bug mostly with gradio 4.43.0 but it also seems to still be present in the latest version (5.8.0) as seen on GitHub.Gradio Environment Information:------------------------------Operating System: Linuxgradio version: 4.44.1gradio_client version: 1.3.0------------------------------------------------gradio dependencies in your environment:aiofiles: 23.2.1anyio: 4.6.2.post1fastapi: 0.115.4ffmpy: 0.4.0gradio-client==1.3.0 is not installed.httpx: 0.27.2huggingface-hub: 0.26.2importlib-resources: 6.4.5jinja2: 3.1.2markupsafe: 2.1.1matplotlib: 3.4.2numpy: 1.21.1orjson: 3.10.11packaging: 21.3pandas: 1.3.5pillow: 10.2.0pydantic: 2.9.2pydub: 0.25.1python-multipart: 0.0.17pyyaml: 6.0ruff: 0.7.2semantic-version: 2.10.0tomlkit==0.12.0 is not installed.typer: 0.12.5typing-extensions: 4.12.2urllib3: 2.2.3uvicorn: 0.32.0authlib; extra == 'oauth' is not installed.itsdangerous; extra == 'oauth' is not installed.gradio_client dependencies in your environment:fsspec: 2024.10.0httpx: 0.27.2huggingface-hub: 0.26.2packaging: 21.3typing-extensions: 4.12.2websockets: 12.0
Severity
I can work around it
The text was updated successfully, but these errors were encountered:
The easy solution is just to make an arbitrary GET / request to initialize the cookies. But that introduces unnecessary network overhead.
The network-friendly solution would be to lazily initialize the cookies on the first (or every) returned response. But that would require refactoring all the httpx calls.
Is there a URL to query that will just return a short response with headers? I see heartbeat, but I don't want a streaming response, just an "alive" message.
Hi @danbgoldman could we do this as part of _get_config()? This gets called once when the Client is initiated. We could append any cookies that are returned to self.cookies
Describe the bug
The python
gradio_client
library does not cache any server cookies unless theClient
constructor is called with password authentication viaauth
argument. (You can see this by inspecting the code: TheClient.cookies
member is only set in one place, on this line, inside the_login
method.)However, cookies are not only used for authentication. They are also needed in other scenarios - such as, properly routing requests when using multiple replicas of a service in Kubernetes. (The documentation mentions using
sessionAffinity
, but this doesn't work with ingress, as explained here.)Have you searched existing issues? 🔎
Reproduction
This bug is reproducible with any demo running in multiple replicas in Kubernetes, when called using the client API. But it's a bit tricky to provide a minimal example here, because it would include docker containers, k8s yamls and all kinds of other things that have nothing to do with gradio.
Screenshot
No response
Logs
No response
System Info
Severity
I can work around it
The text was updated successfully, but these errors were encountered: