gradio: "Event not found in queue" when deploying Gradio behind a proxy
Describe the bug
followed exactly the official tutorial, the web page can show correctly, but if I entered sth in textbox, and click submit, the exception show:
(base) shao@shaothinkbook:~/ctrl-robotic-via-gpt$ cd /home/shao/ctrl-robotic-via-gpt ; /usr/bin/env /home/shao/miniconda3/envs/ctrl-robotic/bin/python /home/shao/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 45695 -- /home/shao/ctrl-robotic-via-gpt/pc_host_main.py
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/gradio/queueing.py", line 223, in push
event_queue = self.event_queue_per_concurrency_id[event.concurrency_id]
KeyError: '139787653332224'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
return await self.app(scope, receive, send)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
raise exc
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
await self.app(scope, receive, _send)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/gradio/route_utils.py", line 695, in __call__
await self.simple_response(scope, receive, send, request_headers=headers)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/gradio/route_utils.py", line 711, in simple_response
await self.app(scope, receive, send)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
raise exc
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/routing.py", line 756, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/routing.py", line 776, in app
await route.handle(scope, receive, send)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/routing.py", line 297, in handle
await self.app(scope, receive, send)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/routing.py", line 77, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
raise exc
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/starlette/routing.py", line 72, in app
response = await func(request)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/fastapi/routing.py", line 278, in app
raw_response = await run_endpoint_function(
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
return await dependant.call(**values)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/gradio/routes.py", line 747, in queue_join
return await queue_join_helper(body, request, username)
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/gradio/routes.py", line 765, in queue_join_helper
success, event_id = await blocks._queue.push(
File "/home/shao/miniconda3/envs/ctrl-robotic/lib/python3.10/site-packages/gradio/queueing.py", line 225, in push
raise KeyError(
KeyError: 'Event not found in queue. If you are deploying this Gradio app with multiple replicas, please enable stickiness to ensure that all requests from the same user are routed to the same instance.'
can get to work by downgrade to 4.8.0:
pip install gradio==4.8.0
Have you searched existing issues? 🔎
- I have searched and found no existing issues
Reproduction
import gradio as gr
def greet(name,):
return "Hello, " + name + "!"
demo = gr.Interface(
fn=greet,
inputs=[gr.Textbox(label="command to robot")],
outputs=["text"],
)
demo.launch()
Screenshot
No response
Logs
No response
System Info
> Windows 11 wls2, ubuntu22.
> (ctrl-robotic) shao@shaothinkbook:~/ctrl-robotic-via-gpt$ pip freeze | grep gradio
> gradio==4.27.0
> gradio_client==0.15.1
> Python 3.10
Severity
Blocking usage of gradio
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 18 (6 by maintainers)
you can try
export no_proxy="localhost,127.0.0.1"before running the gradio appI am also encountering this issue, running Gradio on Kubernetes with Ray Serve and a single replica:
Here is the serve
config.yaml:Downgrading with
pip install gradio==4.24.0fixed the issue.I have updated to gradio 4.31.1 and still see this error with
http_proxyandhttps_proxyset. And byunset http_proxyandunset https_proxycan fix this issue.Environment
Issue Description
I encountered a
KeyError: 'Event not found in queue'when running a Python program that uses Gradio on an Ubuntu 22.04 server, connected via SSH from a Windows machine(Same LAN). This setup involves a reverse proxy using the following environment variables:where <windows-ip> and <port> are the IP and port of the proxy software on Windows.
Steps to Reproduce Set up a reverse proxy using the above environment variables. Run a Python program with Gradio on the server.
Error Message
Temporary Solution Adding export no_proxy=“localhost,127.0.0.1” to the environment variables before running the Gradio app resolves the issue.