-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Video component can't download URL behind a proxy #10726
Comments
What proxy are you using? Can you explain how you set it up so we can try to reproduce this? |
This is behind a "corporate" web proxy, e.g. https://www.squid-cache.org/. |
Hmm this might be tricky to reproduce, but are you certain https://github.com/intel-iot-devkit/sample-videos/raw/master/person-bicycle-car-detection.mp4 is accessible through your proxy? What happens when you run this: import requests
url = "https://github.com/intel-iot-devkit/sample-videos/raw/master/person-bicycle-car-detection.mp4"
response = requests.get(url, stream=True)
if response.status_code == 200:
print("File is accessible. Saving...")
with open("person-bicycle-car-detection.mp4", "wb") as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
print("Download complete.")
else:
print(f"Failed to access file. HTTP Status Code: {response.status_code}") |
I kind of confirmed this issue, by installing the Squid Web Proxy, and running a test app with http_proxy and https_proxy env vars. Install Squid: https://documentation.ubuntu.com/server/how-to/web-services/install-a-squid-server/index.html Do a test request: export https_proxy=http://localhost:3128
export http_proxy=http://localhost:3128
curl www.google.com Check the access log: sudo cat /var/log/squid/access.log The log shows: 1741122617.179 109 ::1 TCP_MISS/200 17789 GET http://www.google.com/ - HIER_DIRECT/142.250.217.100 text/html Now, write a test application: import gradio as gr
def create_interface():
with gr.Blocks() as demo:
gr.Video(
label="Input Video",
interactive=True,
value="https://github.com/intel-iot-devkit/sample-videos/raw/master/person-bicycle-car-detection.mp4",
sources="upload",
)
return demo
demo = create_interface()
demo.launch(
server_name="0.0.0.0",
server_port=7860,
) Run it: python test.py Check the access logs again: sudo cat /var/log/squid/access.log There are a bunch of requests, but no one for the video: 1741122617.179 109 ::1 TCP_MISS/200 17789 GET http://www.google.com/ - HIER_DIRECT/142.250.217.100 text/html
1741122630.016 178 127.0.0.1 TCP_TUNNEL/200 5883 CONNECT api.gradio.app:443 - HIER_DIRECT/52.41.19.48 -
1741122630.516 1 127.0.0.1 TCP_REFRESH_MODIFIED/200 227 GET http://localhost:7860/gradio_api/startup-events - HIER_DIRECT/127.0.0.1 application/json
1741122630.516 101 127.0.0.1 TCP_TUNNEL/200 5902 CONNECT api.gradio.app:443 - HIER_DIRECT/52.41.19.48 -
1741122630.531 11 127.0.0.1 TCP_REFRESH_MODIFIED/200 234 HEAD http://localhost:7860/ - HIER_DIRECT/127.0.0.1 text/html
1741122635.915 5566 127.0.0.1 TCP_TUNNEL/200 7554 CONNECT huggingface.co:443 - HIER_DIRECT/99.84.66.65 - Just to be 100% sure, download a video with Curl and check that it shows up in the log:
1741122973.831 403 ::1 TCP_TUNNEL/200 7671 CONNECT github.com:443 - HIER_DIRECT/140.82.116.4 - So, the Video component is not using the proxy setup in |
I think a simple way to test is: set a bad proxy configuration. python3 -m venv test
source ./test/bin/activate
pip install gradio
export http_proxy=http://a.random.proxy.address.com:911
export https_proxy=http://a.random.proxy.address.com:911
export no_proxy=localhost,127.0.0.1 This is the test application, with another video import gradio as gr
import logging
logging.basicConfig(level=logging.DEBUG)
def create_interface():
with gr.Blocks() as demo:
gr.Video(
label="Input Video",
interactive=True,
value="https://download.samplelib.com/mp4/sample-5s.mp4",
sources="upload",
)
return demo
demo = create_interface()
demo.launch(
server_name="0.0.0.0",
server_port=7860,
) Run the app gradio test.py And this are the logs:
There are network requests failing because of the bad proxy setting, but the video request doesn't pass through the proxy so it works. |
Describe the bug
When I use Video with a URL as value, and run gradio behind a proxy, Video fails to download the url:
This code doesn't work:
The fail log is the following:
We thought it was a proxy misconfiguration. But looks like Video ignores our proxy settings (env vars http_proxy and https_proxy).
After changing our code to:
It started working (download_file uses requests to pull the file, looks like that one respects the proxy)
Have you searched existing issues? 🔎
Reproduction
You need to be behind a network proxy. Configure the proxy and do:
App will fail to start
Screenshot
No response
Logs
System Info
Severity
I can work around it
The text was updated successfully, but these errors were encountered: