hf-hub icon indicating copy to clipboard operation
hf-hub copied to clipboard

Connection Timeout

Open Jordan-Haidee opened this issue 1 year ago • 10 comments
trafficstars

In my Windows OS, when I run the example:

use hf_hub::api::sync::Api;

fn main() {
    let api = Api::new().unwrap();

    let repo = api.model("bert-base-uncased".to_string());
    let _filename = repo.get("config.json").unwrap();
}
  • It always raise Connect Timeout exception. I tried to use proxy, but it didn't work too.
  • If using Python huggingface_hub package, the exception didn't happen. image

Jordan-Haidee avatar Jan 13 '24 02:01 Jordan-Haidee

The same problem, but it works fine after cloning hf-hub to the project directory.

[dependencies] hf-hub = { path = "./rust-lib/hf-hub" }

liafuzho avatar Jan 18 '24 15:01 liafuzho

Thanks, let me have a try.

Jordan-Haidee avatar Jan 22 '24 07:01 Jordan-Haidee

I cannot read that error message in Chinese, sorry.

Seems like there was an issue connecting to huggingface.co and I think connecting to it from China is causing regular issues. It looks like a regular network issue.

Narsil avatar Jan 22 '24 16:01 Narsil

Edit: One hour later it is now working again. I didn't do anything (other than sit in the hot tub).

I am suddenly having issues with this as well on Ubuntu (from USA).

The same hf-hub code and repo that I was using a few weeks ago no longer works.

Regular git requests to hf.co work fine.

Cloning hf-hub from git and loading from path in Cargo.toml does not help.

In order to match this issue I tried bert-base-uncased:

thread 'main' panicked at src/main.rs:18:45:
called `Result::unwrap()` on an `Err` value: RequestError(Transport(Transport { kind: Io, message: None, url: Some(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("huggingface.co")), port: None, path: "/bert-base-uncased/resolve/main/README.md", query: None, fragment: None }), source: Some(Custom { kind: TimedOut, error: "timed out reading response" }) }))

danielclough avatar Jan 25 '24 06:01 danielclough

The same problem, but it works fine after cloning hf-hub to the project directory.

[dependencies] hf-hub = { path = "./rust-lib/hf-hub" }

Thanks! This solved the problem for me. I have a proxy by setting HTTP_PROXY to reach the hugging face hub without any issue. Maybe it's somehow not able to read this environment variable causing this issue.

garyli1019 avatar Jan 27 '24 12:01 garyli1019

Which versions are you guy using ? We may just need to make a new release (although I' m not sure we made any change whatsoever since the last release)

Narsil avatar Jan 31 '24 17:01 Narsil

Just the latest 0.3.2

Jordan-Haidee avatar Feb 01 '24 10:02 Jordan-Haidee

Just the latest 0.3.2

Jordan-Haidee avatar Feb 01 '24 10:02 Jordan-Haidee

@Narsil when can we have a new version which includes the proxy setting?

npuichigo avatar Apr 22 '24 15:04 npuichigo

Ordinary proxies cannot be used in China. To solve this problem, sock5 support is required. I have added pr for this purpose.

Before pr is merged, you can directly use the following version to automatically obtain socks5 proxy in system.

hf-hub = { git = "https://github.com/oovm/hf-hub" }

make sure you are using

export http_proxy="socks5://127.0.0.1:7890"
export https_proxy="socks5://127.0.0.1:7890"

oovm avatar Aug 09 '24 07:08 oovm

There is no need for that.

You always could enable socks on your own projects. It's showcased here: https://github.com/huggingface/hf-hub/pull/81

It's important we do not enable that feature by default, because otherwise:

We need to add every transient feature of every dependency, which is at least cumbersome.
We don't want users to be compiling the most complex versions of dependency if they don't need it.

This is to the best of my understanding how feature were designed and created.

Narsil avatar Dec 25 '24 22:12 Narsil

Closing the issue since I gave a solution to this issue. Feel free to reopen if this doesn't solve it.

Narsil avatar Dec 30 '24 15:12 Narsil