jcastill
(Jose)
August 30, 2023, 5:06pm
1
What is the problem you are having with rclone?
I suspect there's a problem with the flag --bind when using --bind 0.0.0.0 to bind to IPv4 interface
Run the command 'rclone version' and share the full output of the command.
rclone version
rclone v1.63.1
os/version: debian 11.7 (64 bit)
os/kernel: 5.10.0-19-amd64 (x86_64)
os/type: linux
os/arch: amd64
go/version: go1.20.6
go/linking: static
go/tags: none
Which cloud storage system are you using? (eg Google Drive)
Microsoft OneDrive
The command you were trying to run (eg rclone copy /tmp remote:tmp
)
rclone sync GDrive: OneDrive: --onedrive-no-versions --onedrive-chunk-size 160M --bind 0.0.0.0 --log-level INFO --log-file /home/sync/sync.log
The rclone config contents with secrets removed.
[OneDrive] type type = onedrive
client_id = xxxx
client_secret = xxxx
token = {"access_token":"xxxx"}
drive_id = xxx
drive_type = business
auth_url = https://login.microsoftonline.com/xxxx/oauth2/v2.0/authorize
token_url = https://login.microsoftonline.com/xxxx/oauth2/v2.0/token
[GDrive]
type = drive
client_id = xxxx
client_secret = xxxx
scope = drive
token = {"access_token":"xxxx"}
root_folder_id = xxxx
team_drive =
A log from the command with the -vv
flag
Do not have it handy as it also depends on OeDrive failing with this error:
Failed to copy: resourceModified: The resource has changed since the caller last read it; usually an eTag mismatch
Upon troubleshooting it I saw it a couple of times I did it with -vv flag but unfortunately didn't capture the log entry, but saw the connection closed was with an IPv6 address and therefore started to test if IPv4 fixed it.
I tried --disable-http2 flag as well but that didn't help. I noticed that if I do --bind 0.0.0.0 it will still use IPv6, but if I use --bind "my real ipv4" I do get binded to IPv4 and the eTag mismatch goes away.
I'm trying to recreate the error and will share the logs once I do. But wanted to open the forum post in case other people are having this problem and might try the workaround that is working for me or if somebody might be able to give more information about this.
Thanks!
What is the issue/challenge/problem with it using IPV6?
jcastill
(Jose)
August 30, 2023, 5:22pm
3
My ISP sometimes has issues with IPv6 so I try to route most of my traffic via IPv4.
I also just got throttled and can see it was trying to use IPv6:
2023/08/30 13:16:36 DEBUG : pacer: low level retry 1/10 (error Put "https://xxxx.sharepoint.com/sites/Backup/_api/v2.0/drives/xxxx/items/xxxx/uploadSession?guid='xxxx'&overwrite=True&rename=False&dc=0&tempauth=xxxx": write tcp [xxxx:xxxx:xxx:xxxx::]:38995->[xxxx:xxxx:xxxx::x]:443: write: connection reset by peer) 2023/08/30 13:16:36 DEBUG : pacer: Rate limited, increasing sleep to 20ms 2023/08/30 13:16:43 DEBUG : pacer: Reducing sleep to 15ms
I would expect it to be an IPv4 as the command I tested with was:
rclone sync GDrive: OneDrive: --onedrive-no-versions --onedrive-chunk-size 160M --bind 0.0.0.0 --log-level DEBUG --log-file /home/sync/sync.log -P
There is a known enhancement/bug/issue with this already:
rclone:master
← buengese:dial-ipv4
opened 04:12PM - 13 Jun 22 UTC
<!--
Thank you very much for contributing code or documentation to rclone! Plea… se
fill out the following questions to make it easier for us to review your
changes.
You do not need to check all the boxes below all at once, feel free to take
your time and add more commits. If you're done and ready for review, please
check the last box.
-->
#### What is the purpose of this change?
<!--
Describe the changes here
-->
Implement a way force rclone to use IPv4/IPv6 on a dual-stack network as requested in #6124 . This was the simplest way I could think of that should have desired effect.
Limitations include this forcing the dialer to make tcp connections only. This shouldn't be problem for `net/http` since HTTP/1.1 and HTTP/2 are tcp only .
I might have also missed other problems with this approach.
Alternative ways of achieving this is modifying address resolution probably by providing a custom resolver to the dialer.
#### Checklist
- [x] I have read the [contribution guidelines](https://github.com/rclone/rclone/blob/master/CONTRIBUTING.md#submitting-a-new-feature-or-bug-fix).
- [x] I have added tests for all changes in this PR if appropriate.
- [ ] I have added documentation for the changes if appropriate.
- [ ] All commit messages are in [house style](https://github.com/rclone/rclone/blob/master/CONTRIBUTING.md#commit-messages).
- [ ] I'm done, this Pull Request is ready for review :-)
as it's been around for a bit of time.
Not sure your issue is related to IPV6 but normal MS throttling as you are not limiting any TPS.
jcastill
(Jose)
August 30, 2023, 5:49pm
5
As I'm sure you are aware Microsoft has the most undocumented/random rate limits around. I have tried ---tpslimit 5 and still get randomly throttled, sometimes it's copying some big files it will close the connection and rate limit for 5 seconds up to 5 minutes.
During my analysis seems they throttle also based on tenant and not just account, as I have multiple accounts and got throttled heavy when multiple accounts were syncing at the same time. We have since adjusted so they run at different times and helped a lot.
Now, just to explain, my problem/question is why --bind 0.0.0.0 is not binding rclone to IPv4 as expected and to let people know that seems the eTag mismatch (which there seems to be a couple of forum posts around this) seems to be related to Microsoft and their IPv6 servers as it doesn't happen to me using IPv4 and only when using IPv6.
See pull request I linked above.
ncw
(Nick Craig-Wood)
August 30, 2023, 6:12pm
7
This is actually a bug in the go stdlib. Unfortunately the maintainers didn't agree.
opened 02:28PM - 01 Oct 21 UTC
closed 04:54PM - 04 Oct 21 UTC
NeedsInvestigation
FrozenDueToAge
<!--
Please answer these questions before submitting your issue. Thanks!
For q… uestions please use one of our forums: https://github.com/golang/go/wiki/Questions
-->
### What version of Go are you using (`go version`)?
<pre>
go version go1.17.1 linux/amd64
</pre>
### Does this issue reproduce with the latest release?
Yes
### What operating system and processor architecture are you using (`go env`)?
<details><summary><code>go env</code> Output</summary><br><pre>
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ncw/.cache/go-build"
GOENV="/home/ncw/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ncw/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ncw/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go/go1.17"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go/go1.17/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.1"
GCCGO="/usr/bin/gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3014442064=/tmp/go-build -gno-record-gcc-switches"
</pre></details>
### What did you do?
Run this program
```go
package main
import (
"fmt"
"log"
"net"
"os"
"os/exec"
"strings"
)
func main() {
if len(os.Args) != 2 {
log.Fatalf("Syntax: %s bind_address", os.Args[0])
}
bindAddr := os.Args[1]
go func() {
_, err := net.Listen("tcp", bindAddr)
if err != nil {
log.Fatalf("net.Listen failed: %v", err)
}
}()
// Read netstat
cmd := exec.Command("netstat", "-tuanp")
out, err := cmd.Output()
if err != nil {
log.Fatal(err)
}
// Print netstat lines with our PID in
pid := fmt.Sprint(os.Getpid())
for _, line := range strings.Split(string(out), "\n") {
if strings.Contains(line, pid) {
fmt.Println(line)
}
}
}
```
I get this
```
$ ./listen-bug 127.0.0.1:1234
tcp 0 0 127.0.0.1:1234 0.0.0.0:* LISTEN 3179765/./listen-bu
$ ./listen-bug 0.0.0.0:1234
tcp6 0 0 :::1234 :::* LISTEN 3179773/./listen-bu
```
Note the second of these is listening on IPv6 even though we explictly gave it an IPv4 bind address.
### What did you expect to see?
I expected to see it not binding to IPv6 addresses, something like this
```
$ ./listen-bug 0.0.0.0:1234
tcp 0 0 0.0.0.0:1234 0.0.0.0:* LISTEN 3179765/./listen-bu
```
### What did you see instead?
I see it binding to IPv4 and IPv6 addresses
```
$ ./listen-bug 0.0.0.0:1234
tcp6 0 0 :::1234 :::* LISTEN 3179773/./listen-bu
```
This was originally discussed in the [rclone forum](https://forum.rclone.org/t/rc-listening-on-ipv4-v6-socket-instead-only-ipv4/26768)
I guess I could manually force the tcp4 proto if we see 0.0.0.0 that would be an easy workaround I think.
jcastill
(Jose)
August 30, 2023, 6:34pm
8
Thanks Nick. I guess I will update my scripts to bind to their respective IPv4 address.
I'll continue to monitor and see if I find any more details on the eTag mismatch using IPv6. I will force a couple of the scripts to use IPv6 and see if they get them while IPv4 do not and report back.
ncw
(Nick Craig-Wood)
August 30, 2023, 10:57pm
9
The idea of using 0.0.0.0 to force IPv4 wasn't very difficult to implement.
Please give this a go
You can use --bind 0.0.0.0
to force rclone to use IPv4 addresses and --bind ::0
to force rclone to use IPv6 addresses.
v1.64.0-beta.7296.ad204d0dc.fix-bind on branch fix-bind (uploaded in 15-30 mins)
1 Like
jcastill
(Jose)
September 1, 2023, 4:40am
10
Hey Nick, been testing and so far seems to be working fine. Amazing work as always, thanks!
ncw
(Nick Craig-Wood)
September 1, 2023, 9:49am
11
Thank you for testing
I've merged this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.64
1 Like
system
(system)
Closed
September 4, 2023, 9:49am
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.