gradio icon indicating copy to clipboard operation
gradio copied to clipboard

Using gradio with HTTP2

Open DanielleChasonAporia opened this issue 1 year ago • 7 comments

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: image

Screenshot

The error I get: image

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

DanielleChasonAporia avatar Oct 05 '23 14:10 DanielleChasonAporia

This https://github.com/gradio-app/gradio/issues/2260#issuecomment-1256779142 probably helps?

henryruhs avatar Oct 05 '23 15:10 henryruhs

Does anyone have an idea?

DanielleChasonAporia avatar Oct 25 '23 07:10 DanielleChasonAporia

@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.

arian81 avatar Mar 05 '24 14:03 arian81

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.

abidlabs avatar Mar 05 '24 21:03 abidlabs

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.

arian81 avatar Mar 05 '24 21:03 arian81

Yes and what happens when you try setting to http2? Do you see the same issue that @DanielleChasonAporia described?

abidlabs avatar Mar 05 '24 21:03 abidlabs

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.

arian81 avatar Mar 05 '24 22:03 arian81

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?

image

abidlabs avatar Mar 25 '24 23:03 abidlabs

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?

image

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.

arian81 avatar Mar 26 '24 19:03 arian81

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.

abidlabs avatar Mar 26 '24 21:03 abidlabs