croc icon indicating copy to clipboard operation
croc copied to clipboard

Suggestion: auto-retry?

Open omgitsraven opened this issue 5 years ago • 7 comments

I'm trying to send a large file to a friend who has a flaky connection, and while the resume function is working, we always have to manually re-connect on both ends every time something goes wrong, which means that the transfer can't continue until we're both back at our keyboards.

Specifically, on the sending end I'm seeing:

file.7z  28% |█████               | (3.8 MB/s) [5m8s:3h18m53s]panic: wanted to write 32814 but wrote 0: write tcp 192.168.0.187:61046->142.---.---.---:9010: wsasend: An existing connection was forcibly closed by the remote host.

goroutine 15 [running]:
github.com/schollz/croc/v6/src/croc.(*Client).sendData(0xc00003d200, 0x0)
        /home/zns/go/src/github.com/schollz/croc/src/croc/croc.go:988 +0x7cf
created by github.com/schollz/croc/v6/src/croc.(*Client).updateState
        /home/zns/go/src/github.com/schollz/croc/src/croc/croc.go:842 +0x222

Does that seem like the type of error that, rather than crashing, both ends could safely recognize and auto-reattempt (like once a minute or so) until the connection is re-established? Or does the NAT traversal situation mean that we'd have to go through the relay again? (Even then, while I understand that you wouldn't want TOO much traffic to the relay coming from auto-reattempts running all day, maybe trying three times before giving up or something wouldn't be too much of an extra load?)

omgitsraven avatar Aug 10 '19 18:08 omgitsraven

@omgitsraven I like this idea.

Maybe it could be a flag? Like --reconnect, where if its enabled it will keep reconnecting on broken connections.

schollz avatar Aug 12 '19 03:08 schollz

That could work, although it'd either mean suffering one failed attempt in order to find out you need it, or else including the flag all the time just in case you do... Like, what would be someone's motivation not to use the flag just in case?

omgitsraven avatar Aug 12 '19 13:08 omgitsraven

Enabled by default seems like an good option for me. I throws a panic, so recover will be enough to try again. You can maybe set a default flag to retry attempts (like 3 or so).

golubaca avatar Sep 04 '20 19:09 golubaca

Mixing all answers together would mean that it is enabled by default and a flag like --no-reconnect is added to prevent croc from automatically reconnecting, which is a behavior I would definitely agree with.

nikoksr avatar Sep 28 '20 17:09 nikoksr

@schollz I agree with @nikoksr. I would like this feature as well. Let me know what you want for this. Should the default be to auto reconnect if the transfer fails and a flag to disable? I'm still figuring out the code base, thank you.

hsm2k3 avatar Jul 29 '22 03:07 hsm2k3

@schollz I agree with @nikoksr. I would like this feature as well. Let me know what you want for this. Should the default be to auto reconnect if the transfer fails and a flag to disable? I'm still figuring out the code base, thank you.

I'm not sure about the default. For now, just make a flag for it and I can think about it for a default. Let me know if you have any questions about the codebase as you dig in for the PR

schollz avatar Jul 31 '22 00:07 schollz

Please dont forget this feature

formtapez avatar Apr 02 '24 15:04 formtapez