qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
27.67k stars 3.92k forks source link

SOCKS5 proxy disconnect issue due to insufficient retries #12583

Closed FranciscoPombal closed 3 years ago

FranciscoPombal commented 4 years ago

EDIT: for users having trouble with this, use the test build linked here: https://github.com/qbittorrent/qBittorrent/issues/12583#issuecomment-619298534, it should be able to re-establish connection after disconnect errors.

Follow up to https://github.com/qbittorrent/qBittorrent/issues/11735#issuecomment-615831521 @arvidn for your convenience.

Cunningcory commented 4 years ago

I just love every year or so having to re-follow a new thread on basically the same issue since the others keep getting closed without being fixed. SOCKS5 has never worked for me, and I've always tried newer builds without any difference, including the next to last one posted on the most recent closed discussion. I'm in the middle of testing the current build and was going to give feedback, but the thread was closed. Can I give feedback here?

This is the build I'm testing: https://github.com/qbittorrent/qBittorrent/issues/11735#issuecomment-617230156

The build before this timed out after a day or so, which has been the main issue for several years now. No errors yet on the linked build, but it hasn't been 24 hours yet.

FranciscoPombal commented 4 years ago

@Cunningcory

I just love every year or so having to re-follow a new thread on basically the same issue since the others keep getting closed without being fixed. SOCKS5 has never worked for me, and I've always tried newer builds without any difference, including the next to last one posted on the most recent closed discussion. I'm in the middle of testing the current build and was going to give feedback, but the thread was closed. Can I give feedback here?

Umm, yes? Did you read https://github.com/qbittorrent/qBittorrent/issues/11735#issuecomment-618101331? This issue report was opened specifically to track this disconnect issue, which is the important thing now. The other thread was already filled with unrelated information. It is easier to track this single issue with a clean slate.

This is the build I'm testing: #11735 (comment)

The build before this timed out after a day or so, which has been the main issue for several years now. No errors yet on the linked build, but it hasn't been 24 hours yet.

Might as well test with 4.2.4, it has been officially released. But to be honest, until further changes happen in libtorrent, it is likely that some SOCKS5 issues will remain, as noted in https://github.com/qbittorrent/qBittorrent/issues/11735#issuecomment-615831521

HnyBear commented 4 years ago

Is this where we're suppose to come if we're still having socks5 issues? If so this is the error I keep getting then it hangs with nothing downloading.

4/22/2020 6:30 AM - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: The semaphore timeout period has expired ep: 46.166.190.172:1080

xavier2k6 commented 4 years ago

Is this where we're suppose to come if we're still having socks5 issues? If so this is the error I keep getting then it hangs with nothing downloading.

4/22/2020 6:30 AM - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: The semaphore timeout period has expired ep: 46.166.190.172:1080

@HnyBear Just for clarification, is this with the build from https://github.com/qbittorrent/qBittorrent/issues/11735#issuecomment-617230156 or the official 4.2.4 that has been released?

HnyBear commented 4 years ago

The 11735 build

GregariousJB commented 4 years ago

SOCKS5 has never worked for me, and I've always tried newer builds without any difference

@Cunningcory Same issue here, but I've found that Qbittorrent v 4.1.9.1 doesn't disconnect my SOCKS5 connection at all (first with PrivateInternetAccess, then with TorGuard). All of the versions before it (starting with 4.0) and after it did, but 4.1.9.1 is good. I have no idea why, just letting you know if you want to use it while this issue gets fixed. I haven't tried 4.2.4 yet so perhaps I'm mistaken and everything is fine now, but I've had to wrestle with this program so much the last few years I'm taking a break and staying on what works.

Direct download link for v4.1.9.1 I found for you: https://www.fosshub.com/qBittorrent-old.html?dwl=qbittorrent_4.1.9.1_x64_setup.exe

It's hosted here in case you need a different download, or 32-bit: https://www.fosshub.com/qBittorrent-old.html

That's not a point of spite, by the way. I love you guys working on this and I wish you luck. I'm just gonna take a seat and hope for the best.

Cunningcory commented 4 years ago

@GregariousJB Thanks! I'm currently testing this alpha build, but if that fails on me I'll try 4.1.9.1. My solution has been to run torrents on a virtual machine that runs the full proxy instead of SOCKS5. I STILL have to run a babysitter program that restarts Qbit anytime the proxy has to reconnect, though!

arvidn commented 4 years ago

the best thing to do, for someone experiencing socks5 not working and wanting it to be fixed, is to post a wireshark dump of the UDP ASSOCIATE socks5 connection. Ideally just that TCP stream, to keep the noise down.

It probably won't get fixed unless it breaks (or is demonstrated breaking) for someone able to fix it.

arvidn commented 4 years ago

I suppose this specific issue isn't about socks5 not working, it's about it working and then getting the "semaphore timeout period expired" and it no longer working. I believe this is a windows phenomenon, is that right?

FranciscoPombal commented 4 years ago

I suppose this specific issue isn't about socks5 not working, it's about it working and then getting the "semaphore timeout period expired" and it no longer working.

It's definitely working for a while before it stops working, from what the users say. I don't know enough about this to be sure that the exact cause for the transition from working -> not working is then getting the "semaphore timeout period expired" though.

I believe this is a windows phenomenon, is that right?

No idea, honestly. Most of the qBittorrent on user base is on Windows, but that does not necessarily mean this only affects Windows. We'd some Linux/macOS users that use this to confirm.

Cunningcory commented 4 years ago

Still getting the handshake error with 11735 :(

arvidn commented 4 years ago

@Cunningcory do you have a link to "the handshake error"? Or could you describe what you mean by it?

xavier2k6 commented 4 years ago

@arvidn This is what @Cunningcory means below (from previous issue/thread) https://github.com/qbittorrent/qBittorrent/issues/11735#issuecomment-616854964

4/20/2020 5:38 PM - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: The semaphore timeout period has expired ep: 109.201.138.233:1080
4/20/2020 5:38 PM - SOCKS5 proxy error. Message: SOCKS5 error. op: handshake ec: End of file ep: 109.201.154.198:1080
Cunningcory commented 4 years ago

@arvidn Xavier is correct, that's the error. This is why I don't understand why the other thread was locked down as the discussion was troubleshooting "proxies and UDB issues". I guess this is just to get more specific to SOCKS5? It just feels like having to start from scratch with the troubleshooting.

For me and seems most people this has always been the issue for years. You start qbittorrent and everything is working fine with SOCKS5. Then you return later and it isn't working. You then restart the Qbit (maybe several times) and then it works again for a brief amount of time. This is the problem I have always had, so I guess I'm confused as to what other issues have been fixed.

@GregariousJB I'm trying 4.1.9.1 now but I don't have high hopes. I'll let you know!

arvidn commented 4 years ago

@Cunningcory most of the issues fixed in socks5 recently were related to regressions in libtorrent 1.2.x that were exposed as qBT transitioned over to the new version of libtorrent

FranciscoPombal commented 4 years ago

This is why I don't understand why the other thread was locked down as the discussion was troubleshooting "proxies and UDB issues". I guess this is just to get more specific to SOCKS5? It just feels like having to start from scratch with the troubleshooting.

The other issue was closed because it was an "umbrella issue" for many different problems, most of which have been fixed. The notable exception is this one SOCKS5 issue. So this issue was opened to:

Of course, some things have to be copy-pasted back here, but it's not much in this case (anyone can copy-paste 2 log lines), so I think it's worth it.

arvidn commented 4 years ago

could someone give this a try? https://github.com/arvidn/libtorrent/pull/4579

HnyBear commented 4 years ago

I've upgraded to 4.2.4 and still have the error below. IF there is more info I can provide please let me know.

4/24/2020 6:03 AM - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: The semaphore timeout period has expired ep: 109.201.154.133:1080

sdkane commented 4 years ago

4.2.4 running in a docker container No permanent disconnect issues yet, but some temporary. The log shows this error 8 times before successfully reconnecting

(W) 2020-04-24T13:05:00 - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: End of file ep: 123.45.67.8:1080
(I) 2020-04-24T13:06:59 - Detected external IP: 123.45.67.8
PinkFromTheFuture commented 4 years ago

socks5 is not working for me with this version, but I don't see anything on the terminal. Do I need to launch it with a parameter or do I need a specific build to see debug messages?

[pink@gram qbittorrent-4.2.4]$ ldconfig -p | grep libtorrent
        libtorrent.so.21 (libc6,x86-64) => /usr/lib/libtorrent.so.21
        libtorrent.so (libc6,x86-64) => /usr/lib/libtorrent.so
        libtorrent-rasterbar.so.10 (libc6,x86-64) => /usr/lib/libtorrent-rasterbar.so.10
        libtorrent-rasterbar.so (libc6,x86-64) => /usr/lib/libtorrent-rasterbar.so
[pink@gram qbittorrent-4.2.4]$ qbittorrent --version
qBittorrent v4.2.4
FranciscoPombal commented 4 years ago

@xavier2k6 can you provide a Windows build with https://github.com/arvidn/libtorrent/pull/4579 please?

xavier2k6 commented 4 years ago

~@FranciscoPombal Just finished compiling...will upload soon & edit this message.~

@arvidn below are the three main errors being experienced by users in this thread.

Message: SOCKS5 error. op: handshake ec: End of file

Message: SOCKS5 error. op: sock_read ec: End of file

Message: SOCKS5 error. op: sock_read ec: The semaphore timeout period has expired

@HnyBear @Cunningcory @GregariousJB care to give below a try.

Based off of qBittorrent master https://github.com/qbittorrent/qBittorrent/commit/480e732694392cc39d65c7e6394f57274d8fb025 & https://github.com/arvidn/libtorrent/pull/4579/commits/cb318bedc5e337ca7dea80db0174725b770e61db

windows x64 test build with patch for retry failed socks5 server connections

PinkFromTheFuture commented 4 years ago

Found the log on ~/.local/share/data/qBittorrent/logs/qbittorrent.log

(N) 2020-04-25T00:30:54 - qBittorrent v4.3.0alpha1 started
(N) 2020-04-25T00:30:54 - Using config directory: /home/pink/.config/qBittorrent/
(I) 2020-04-25T00:30:54 - Trying to listen on: 0.0.0.0:8473,[::]:8473
(N) 2020-04-25T00:30:54 - Peer ID: -qB4300-
(N) 2020-04-25T00:30:54 - HTTP User-Agent is 'qBittorrent/4.3.0alpha1'
(I) 2020-04-25T00:30:54 - DHT support [ON]
(I) 2020-04-25T00:30:54 - Local Peer Discovery support [OFF]
(I) 2020-04-25T00:30:54 - PeX support [ON]
(I) 2020-04-25T00:30:54 - Anonymous mode [ON]
(I) 2020-04-25T00:30:54 - Encryption support [ON]
(I) 2020-04-25T00:30:54 - IP geolocation database loaded. Type: DBIP-Country-Lite. Build time: Tue. Mar. 31 19:49:13 2020.
(N) 2020-04-25T00:30:54 - Options were saved successfully.
(I) 2020-04-25T00:30:54 - Successfully listening on IP: 127.0.0.1, port: UDP/8473
(I) 2020-04-25T00:30:54 - Successfully listening on IP: 192.168.0.115, port: UDP/8473
(I) 2020-04-25T00:30:54 - Successfully listening on IP: ::1, port: UDP/8473
(I) 2020-04-25T00:30:54 - Successfully listening on IP: fe80::ac4c:6dde:e86a:ff2e%wlp0s20f3, port: UDP/8473
(W) 2020-04-25T00:30:54 - SOCKS5 proxy error. Message: SOCKS5 error. op: hostname_lookup ec: No route to host ep: 127.0.0.1:8473
(W) 2020-04-25T00:30:54 - SOCKS5 proxy error. Message: SOCKS5 error. op: hostname_lookup ec: No route to host ep: [::1]:8473
(W) 2020-04-25T00:31:00 - SOCKS5 proxy error. Message: SOCKS5 error. op: hostname_lookup ec: No route to host ep: [fe80::ac4c:6dde:e86a:ff2e%wlp0s20f3]:8473
(I) 2020-04-25T00:31:00 - UPnP / NAT-PMP support [OFF]
arvidn commented 4 years ago

@eduardoxfurtado are you using xavier2k6's build? does socks5 work for you?

Cunningcory commented 4 years ago

SOCKS5 has never worked for me, and I've always tried newer builds without any difference

@Cunningcory Same issue here, but I've found that Qbittorrent v 4.1.9.1 doesn't disconnect my SOCKS5 connection at all (first with PrivateInternetAccess, then with TorGuard). All of the versions before it (starting with 4.0) and after it did, but 4.1.9.1 is good. I have no idea why, just letting you know if you want to use it while this issue gets fixed. I haven't tried 4.2.4 yet so perhaps I'm mistaken and everything is fine now, but I've had to wrestle with this program so much the last few years I'm taking a break and staying on what works.

Direct download link for v4.1.9.1 I found for you: https://www.fosshub.com/qBittorrent-old.html?dwl=qbittorrent_4.1.9.1_x64_setup.exe

It's hosted here in case you need a different download, or 32-bit: https://www.fosshub.com/qBittorrent-old.html

That's not a point of spite, by the way. I love you guys working on this and I wish you luck. I'm just gonna take a seat and hope for the best.

Hey, this has been working for me so far with no errors! Thanks for this! I'm going to give it another day to make sure it doesn't disconnect and then switch to the new test build to see if it works.

@xavier2k6 I don't know if it's an easy task to check the differences between 4.1.9.1 and the most recent build, but I don't get ANY SOCKS5 error on that build so far and torrents are still working. I am checking my torrent IP as well, and it is going through the proxy.

FranciscoPombal commented 4 years ago

@Cunningcory @GregariousJB it's great that it works on an older version, but it would be best to help fix this issue on libtorrent 1.2.x, so that everything can benefit from it, as apart from this bug, it has many improvements over libtorrent 1.1.x (which is what qbittorrent < 4.2.0 uses).

Be sure to post your results with the test build as soon as you can.

HnyBear commented 4 years ago

Still getting error with latest by @xavier2k6 .

4/26/2020 10:19 AM - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: The semaphore timeout period has expired ep: 109.201.154.227:1080

Cunningcory commented 4 years ago

4.1.9.1 stopped working for me. No error messages, but maybe the only difference is the errors aren't logged in that version. Gonna test the new version now.

GregariousJB commented 4 years ago

4.1.9.1 stopped working for me. No error messages, but maybe the only difference is the errors aren't logged in that version. Gonna test the new version now.

Really? I think it stopped working for me maybe 2 times since I got it October 2019, running it 24/7 and never shutting down my PC, but I'm unsure if it's related to the SOCKS5 thing or just a random fluke. Going on 6 days now since I rebooted for an unrelated reason and no problems since.

Running Windows 10 LTSC v1809, in case that's relevant.

arvidn commented 4 years ago

@HnyBear yes, that error is expected. Does SOCKS5 reconnect when that happens? Does socks5 keep working?

Cunningcory commented 4 years ago

@GregariousJB Yeah, I had no error messages but new torrents got stuck at "Downloading metadata...", even though testing my torrent IP showed the proxy was connected. Count yourself lucky! Is it possible you don't have your torrent traffic limited to the proxy alone? You should have "Use proxy only for torrents" selected in the Connection tab. Otherwise it's possible your proxy drops and your connection switches back without you knowing.

GregariousJB commented 4 years ago

@Cunningcory

image

Above settings since I set it up with PrivateInternetAccess around the same time I installed 4.1.9.1, but I switched to Torguard not too long ago.

On that note, which proxy service are you using? Maybe some of them don't play well with SOCKS5 connections? I don't think it's the case, but maybe my issue of getting stuck on "Downloading metadata" was PrivateInternetAccess.

arvidn commented 4 years ago

I think it would be better avoid posting about other topics than the subject of this ticket. if anyone has additional information to contribute, please do so. I think the most interesting thing right now would be to know whether a build with this patch https://github.com/arvidn/libtorrent/pull/4579 fixes the problem or not.

HnyBear commented 4 years ago

@HnyBear yes, that error is expected. Does SOCKS5 reconnect when that happens? Does socks5 keep working?

So far it appears to be reconnecting. I'll let you know if I get any other errors other than these.

4/27/2020 4:01 AM - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: End of file ep: 109.201.154.237:1080
4/27/2020 3:58 AM - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: The semaphore timeout period has expired ep: 46.166.137.212:1080
FranciscoPombal commented 4 years ago

@Cunningcory @GregariousJB Please keep the discussion on topic. This is about fixing the problem for 4.2.x and future versions. Whatever additional problems you encounter on 4.1.x won't be fixed, because that branch won't receive more releases. Any workaround is meant to be just a stop-gap measure, we have to move forward.

FranciscoPombal commented 4 years ago

@arvidn It is probably not very intuitive that the user only sees SOCKS5 error alerts.

It would be useful to have a way of knowing that dispite an error, the connection has been re-established successfully. Something like a socks5_reconnect_alert or something, so that there can be at least one "SOCKS5 proxy reconnect successful" message for every SOCKS5 proxy error. message.

Otherwise, if the user only sees SOCKS5 proxy error. messages, they might think that stuff is broken, even though the connection might have been successfully re-established each time.

condoghost commented 4 years ago

Sorry to be writing here regarding Proxies and UDP issues (no DHT/magnet/metadata/UDP trackers) #11735 but I couldn't work out how to get my message to @arvidn, @sledgehammer999, @xavier2k6 and @FranciscoPombal and all the others involved contributing, testing, commenting on these Socks-5 issues ... Just wanted to extend a "BiG Thank-You" for the perseverance and all the hard work you and others since #11735 opened December 22, 2019 and prior. I know for sure this hasn't been an easy one by any stretch of the imagination and even more so given the onset of this Coronavirus COVID-19 pandemic locking us all down in countries throughout the world. So, from someone who is extremely grateful, in full-lock-down so far for 7-weeks, a couple of weeks prior to the start of this Official 12-week Lock-Down Notice to those at extreme risk - and very likely to remain in lock-down a while longer after that before taking a peak as to "How it's all going out there" ... "Thank-You", "Thank-You", "Thank-You"!

xavier2k6 commented 4 years ago

@GregariousJB @Cunningcory any feedback for the build in https://github.com/qbittorrent/qBittorrent/issues/12583#issuecomment-619298534 please? good or bad.

btripz commented 4 years ago

Hi,

I'm on mint linux and am not getting any sonnection at all using a SOCKS5 proxy,m the error in the log is

28/04/2020 18:28 - SOCKS5 proxy error. Message: SOCKS5 error. op: connect ec: timed out ep: 194.35.233.229:1080

I am currently on build 4.2.5 Anything else that you would need from me just ask..

Cunningcory commented 4 years ago

@xavier2k6 It's been running for a little over 36 hours and still working. There are two error messages in the log:

4/27/2020 6:19 AM - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: End of file ep: 109.201.154.226:1080
4/28/2020 12:21 AM - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: The semaphore timeout period has expired ep: 46.166.186.198:1080

Usually sometime during day two it craps out, so I'll keep an eye out.

FranciscoPombal commented 4 years ago

@Cunningcory As stated here https://github.com/qbittorrent/qBittorrent/issues/12583#issuecomment-619794089, the error is expected; the important thing is to report whether or not it is reconnecting after it fails: https://github.com/qbittorrent/qBittorrent/issues/12583#issuecomment-620052684

FranciscoPombal commented 4 years ago

@btripz Compile libtorrent from source with this patch included: https://github.com/arvidn/libtorrent/pull/4579. Then compile qBittorrent with that libtorrent custom build. You should still see the error, but you should also observe that it reconnects on its own.

arvidn commented 4 years ago

@btripz it sounds like your SOCKS5 server isn't accepting the incoming connection. Are you sure 194.35.233.229:1080 is correct?

testing with nc suggest that nothing is listening on that port on that IP:

$ nc 194.35.233.229:1080
btripz commented 4 years ago

@arvidn it's the address and port given to me by my VPN provider, I'll try again..

edit: after getting a new host I manged to download a torrent, however I am now getting plenty of these in my log file but I still appear to be connected...

28/04/2020 20:26 - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: End of file ep: 195.206.183.191:1080
28/04/2020 20:25 - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: End of file ep: 195.206.183.191:1080
28/04/2020 20:25 - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: End of file ep: 195.206.183.191:1080
28/04/2020 20:25 - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: End of file ep: 195.206.183.191:1080
28/04/2020 20:24 - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: End of file ep: 195.206.183.191:1080
28/04/2020 20:24 - SOCKS5 proxy error. Message: SOCKS5 error. op: sock_read ec: End of file ep: 195.206.183.191:1080
FranciscoPombal commented 4 years ago

@btripz

edit: after getting a new host I manged to download a torrent, however I am now getting plenty of these in my log file but I still appear to be connected...

was this result obtained with 4.2.5 or with a patched build including https://github.com/arvidn/libtorrent/pull/4579?

btripz commented 4 years ago

@btripz

edit: after getting a new host I manged to download a torrent, however I am now getting plenty of these in my log file but I still appear to be connected...

was this result obtained with 4.2.5 or with a patched build including arvidn/libtorrent#4579?

With 4.2.5.

Edit : I have just added a new torrent and it is downloading without any problems.

FranciscoPombal commented 4 years ago

@btripz Thanks for reporting back, but we're only interested in how it runs with the patch, we already know the limitations of the 4.2.5 release.

crafty35a commented 4 years ago

I installed the test build about 36 hours ago, and so far in the log I see three semaphore timeout errors, but everything is still working. I'm not certain that the semaphore timeout error was a 100% indicator of failure before, but so far so good with the reconnection fix.

arvidn commented 4 years ago

the "semaphore timeout" indicates that the connection to the proxy was terminated (but probably by some timeout or limitation of the local system). The main difference with the most recent patch to libtorrent is that it now tries to re-establish the condition under more circumstances than before. There is no log of this re-establishment though.

FranciscoPombal commented 4 years ago

@arvidn

There is no log of this re-establishment though.

Do you plan on adding it?