-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
network timeout error #9264
Comments
Happening in my app too and it's quite severe. I can't put my finger on it but I suspect more issues coming from the latest fastapi. It seems fastapi's including httptools and dnspython now which the older versions did not. I seem to have solved this issues by forcing fastapi back to 0.103.0 but I'm not certain it's really gone. |
What's the workaround, still getting this with 4.43? |
This is what I've done so far, adding this code at the very beginning when using gradio, it's much better and the program rarely gets network errors. import socket
from gradio import analytics
def get_local_ip_address():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip_address = s.getsockname()[0]
s.close()
except:
ip_address = "127.0.0.1"
return ip_address
def _do_normal_analytics_request(data, topic): # 添加 topic 参数
try:
data["ip_address"] = get_local_ip_address()
# 如果你想完全禁用网络请求,可以在这里直接返回
print(f"Analytics request for topic '{topic}' with data: {data}")
return
except Exception as e:
print(f"Analytics request failed for topic '{topic}': {str(e)}")
# 应用猴子补丁
analytics.get_local_ip_address = get_local_ip_address
analytics._do_normal_analytics_request = _do_normal_analytics_request |
But you can completely turn off gradio analytics and it still happens! |
Write about your program, this is so cool, I'll just disable it and it won't report an error |
Just to confirm, everyone here is seeing these errors only on machines that do not have internet access? |
No, for me it's also happening on a machine with internet access. I can't really put my finger on it but disabling analytics doesn't do anything for me 😞 |
You can try disabling the gradio package before importing it, it might help you |
Describe the bug
When using gradio on a server without a network environment, there will be network errors. See the log for specific error information. Every time I have to use the monkey patch to deal with this error, sometimes it doesn't work.
Have you searched existing issues? 🔎
Reproduction
Screenshot
Logs
System Info
Severity
I can work around it
The text was updated successfully, but these errors were encountered: