Skip to content
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

Do not cancel downloads behind proxy just because it is slow #5717

Closed
lostiniceland opened this issue Jul 12, 2018 · 8 comments · Fixed by #5957
Closed

Do not cancel downloads behind proxy just because it is slow #5717

lostiniceland opened this issue Jul 12, 2018 · 8 comments · Fixed by #5957

Comments

@lostiniceland
Copy link
Contributor

PS C:\Dev\git\project> cargo build
 Downloading serde_json v1.0.11
warning: spurious network error (2 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 1705032704 seconds)
warning: spurious network error (1 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 1705032704 seconds)
error: unable to get packages from source

Our company proxy is also scanning the downloaded artefacts. While doing so, it still sends some data (5 bytes/sec), probably in order to keep the connection alive.
Cargo thinks this is to slow and stops with an error.

Can we have an option to ignore this check?

@alexcrichton
Copy link
Member

You should be able to add global .cargo/config configuration like:

[http]
timeout = 1000000

would that work for your use case?

@lostiniceland
Copy link
Contributor Author

Unfortunately not. I am already using a very long timeout.

The error message also does not appear after a certain amount of time(out). It is immediately appearing (I assume as soon as the connection is established). I've tried many things, including a local mirror of the crates.io-index. The index seems to be ok, since it is trying to download the first crate.

As said, and as others have reported, I guess it wouldnt be a problem if our proxy wouldn't send any data. But it does, which must trigger some exception in the cargo chain.

@alexcrichton
Copy link
Member

Hm this may either be a bug in curl, the proxy, or a timeout in curl that we accidentally aren't configuring? I'm not entirely sure unfortunately :(

If you're using a super long timeout already though and it's failing quickly, then that probably means it's a bug in how we're telling curl about timeouts (maybe we're missing one?)

@lostiniceland
Copy link
Contributor Author

Curl provides these two options

An option to override those would probably be enough. Or Cargo sets higher values if a proxy is configured.

@alexcrichton
Copy link
Member

It looks like Cargo doesn't currently have the ability to overrides its configuration of low_speed_limit and that may do the trick! (Providing the ability to override that)

@lostiniceland
Copy link
Contributor Author

Thanks for providing the location. This is exactly our problem since the proxy only sends 5 bytes/sec.

I can try to work on a PR.
Can I just replace my local cargo binary with an updated one for testing? Or is there a better way?

@alexcrichton
Copy link
Member

Ah yeah a cargo build in this repository should produce another cargo binary and you should be able to use that one in-place instead of the already installed version

@lostiniceland
Copy link
Contributor Author

lostiniceland commented Aug 31, 2018

Here´s how to reproduce the issue (adjust tc to your network adapter).

sudo tc qdisc add dev eth0 handle 1: root htb default 11 && sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 5bps && sudo tc class add dev eth0 parent 1:1 classid 1:11 htb rate 5bps

to clear tc call
sudo tc qdisc del dev eth0 root

How to reproduce (you have to limit bandwith after the index is updated and cargo starts downloading crates...otherwise a simple timeout will occur)

  • clear cargo download cache

  • start a cargo build

  • wait for the crate download to start

  • execute the tc command to limit bandwith under 10bps

  • note that the first connection fails with the low-speed...the next retry will timeout because the connection cannot be established quick enough

  • clear tc

Result (without stupid company proxy)

$ cargo build
Downloading log v0.4.4
Downloading termcolor v1.0.2
Downloading rustfix v0.4.2
Downloading tempfile v3.0.3
Downloading lazycell v1.0.0
Downloading hex v0.3.2
Downloading rustc-workspace-hack v1.0.0
warning: spurious network error (2 tries remaining): [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 5 seconds)
warning: spurious network error (1 tries remaining): [7] Couldn't connect to server (Failed to connect to crates.io port 443: Connection timed out)
Fetch [ ] 0.00%

lostiniceland added a commit to lostiniceland/cargo that referenced this issue Sep 1, 2018
lostiniceland added a commit to lostiniceland/cargo that referenced this issue Sep 3, 2018
Fixes rust-lang#5717

low-speed-time was removed because the corresponding curl-option is already set via http.timeout.

removed unnecessary Option.
bors added a commit that referenced this issue Sep 3, 2018
Provide http-config option for curl low-speed-limit/time

Fixes #5717

Provides new override options for curl in Cargo http config-section.

```
[http]
timeout = 2
low-speed-limit = 5
```

Test with the following during crate-download
`sudo tc qdisc add dev eth0 handle 1: root htb default 11 && sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 8bps && sudo tc class add dev eth0 parent 1:1 classid 1:11 htb rate 8bps`

Clear with
`sudo tc qdisc del dev eth0 root`
@bors bors closed this as completed in #5957 Sep 3, 2018
lostiniceland added a commit to lostiniceland/cargo that referenced this issue Sep 4, 2018
Updates rust-lang#5717

Since people tend to copy/paste, the docs should not use the option which will disable curls low-speed-limit. Rather use a value lower than the default of 10
bors added a commit that referenced this issue Sep 4, 2018
Do not use a disabled-option in the docs

Updates #5717

Since people tend to copy/paste, the docs should not use the option which will disable curls low-speed-limit. Rather use a value lower than the default of 10

Also reverts removal of default low-speed-time (30s) in case no timeout is configured
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants