gradio
gradio copied to clipboard
Using gradio with HTTP2
Describe the bug
I have an application which runs on "google cloud run" and has client side that was implemented with gradio. I want my app to run on HTTP2. I configure it on google cloud run, but it seems that gradio does not support HTTP2 at all. I got the error: upstream connect error or disconnect/reset before headers. reset reason: protocol error Is there a solution or a workaround for that? Thank you!
Have you searched existing issues? 🔎
- [X] I have searched and found no existing issues
Reproduction
Try to run gradio application with http2.
I used "google cloud run" in order to do it:
Screenshot
The error I get:
Logs
No response
System Info
Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 3.46.1
gradio_client version: 0.5.3
------------------------------------------------
gradio dependencies in your environment:
aiofiles: 23.2.1
altair: 5.1.2
fastapi: 0.95.2
ffmpy: 0.3.1
gradio-client==0.5.3 is not installed.
httpx: 0.25.0
huggingface-hub: 0.17.3
fsspec: 2023.9.2
httpx: 0.25.0
huggingface-hub: 0.17.3
packaging: 23.2
requests: 2.31.0
typing-extensions: 4.8.0
websockets: 11.0.3
Severity
Blocking usage of gradio
This https://github.com/gradio-app/gradio/issues/2260#issuecomment-1256779142 probably helps?
Does anyone have an idea?
@abidlabs Hey do you have any updates or information on this ? It's a blocking issue for one of our projects where we need to use massive files in gradio but it's not working.
Hi @arian81 are you running into the same error as @DanielleChasonAporia? We haven't had a chance to look into this yet, but its on my todo list.
Hi @arian81 are you running into the same error as @DanielleChasonAporia? We haven't had a chance to look into this yet, but its on my todo list.
Well our issue is more like file size limit. Google doesn't transfer files bigger than 100 mb on http1 so the upload in Gradio never finishes on cloud run.
Yes and what happens when you try setting to http2? Do you see the same issue that @DanielleChasonAporia described?
Yes and what happens when you try setting to http2? Do you see the same issue that @DanielleChasonAporia described?
It's the same exact error.
Hi @arian81 @DanielleChasonAporia I'm looking into this. Can you please share a repro Gradio app container image that I can use to test this end-to-end?
Hi @arian81 @DanielleChasonAporia I'm looking into this. Can you please share a repro Gradio app container image that I can use to test this end-to-end?
![]()
I don't have access to the containers since it's managed by my company's' dev ops team. Hopefully someone else who also has this problem and has created their own container can chime in on this.
Ok let me provide some general guidance:
- Gradio uses FastAPI under the hood, so if you can run a FastAPI app on HTTP2, you should be able to run Gradio as well
- Uvicorn does not support HTTP2, but Hypercorn does
So one approach would be to mount your Gradio app within a simple FastAPI app using the instructions here: https://www.gradio.app/guides/sharing-your-app#mounting-within-another-fast-api-app
Once you've mounted your app, you can run it like this: hypercorn main:app --bind 0.0.0.0:80
I don't know whether Google Cloud Run gives you this flexibility but that would be generally the right approach.
@tiangolo also provides a suggestion here: https://github.com/tiangolo/fastapi/issues/2907#issuecomment-1311309410
If you've tried this and this does not work, and you can provide a minimal repro we can use to investigate the issue, then I'm happy to revisit.