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

Torrents not resuming after vpn connection loss/restore #9195

Closed
mostlyhuman opened this issue Jul 16, 2018 · 23 comments
Closed

Torrents not resuming after vpn connection loss/restore #9195

mostlyhuman opened this issue Jul 16, 2018 · 23 comments
Labels
Duplicate Network Issues related to network connectivity

Comments

@mostlyhuman
Copy link

mostlyhuman commented Jul 16, 2018

Please provide the following information

qBittorrent version and Operating System

Windows 10 x64 Qbit version 4.1.1

What is the problem

Sometime the VPN connection will drop and then automatically reconnect and when it does any torrents that were added during the downtime will not resume, they stay stuck in Downloading... at 0%

What is the expected behavior

that the torrents will automatically resume when it detects the connection has been restored

Steps to reproduce

change the ethernet adapter in qbittorent to a vpn adapter, stop the vpn, add a torrent, restart the vpn connection

@barkdoll
Copy link

barkdoll commented Jul 17, 2018

I am also having the same issue on Win 10x64 running v4.1.1.

I can attest that I am getting the same result as @mostlyhuman. After VPN failure, torrents are displayed as running, but transfer does not continue.

@dynamichael
Copy link

I have the same problem. I must completely restart the program in order for downloading to resume.

@Dobatymo
Copy link

Same problem here. Restarting the program resumes operation.

@barkdoll
Copy link

barkdoll commented Jul 28, 2018

I did some research on this in the meantime, and it looks like it may not be fixable. If you view Reply #6 (sledgehammer_999's comment) on this forum, this is probably due to your VPN virtual network adapter assigning a new local IP address when re-connecting to a server.

I just wanted to provide this in case it gives you all any insight.

@dynamichael
Copy link

I can think of only one workaround that doesn't require human intervention... write a Windows app that detects the drop, waits for the VPN connection to return, then restarts qBittorent.

@mostlyhuman
Copy link
Author

This should be solvable within Qbitorrent, if it detects this state after a timeout period it just needs to reinitialize in the same way it does when the program first starts (the equivalent of restarting) since that is what fixes it. there may be other more elegant ways as well.

@dynamichael
Copy link

I wrote an app anyway... https://github.com/dynamichael/qConnectionSitter

@mostlyhuman
Copy link
Author

mostlyhuman commented Jul 29, 2018

cool, cheers. are you going to post binaries? I could use Win64.

@barkdoll
Copy link

That's awesome. Thank you for writing this. I ended up writing a wrapper script in bash (implemented with Git bash on Windows) to monitor the VPN address and restart qBittorrent on dis/connect. Then I eventually moved my qBittorrent setup to Linux and used the same script. If any of you want to use it let me know, and I will push it and paste the link.

@richflat
Copy link

richflat commented Nov 6, 2018

I signed up just to post a reply to this. I was having the same issue because I force my router to restart every night due to connection issues that plague it. After assigning a local port (I used 53) to PIA, Qbittorent now resumes within 5 minutes after I reconnect PIA.

However this does not resolve my problem of forcing PIA to reconnect on its own after losing connection. argh

@trickinit
Copy link

That's awesome. Thank you for writing this. I ended up writing a wrapper script in bash (implemented with Git bash on Windows) to monitor the VPN address and restart qBittorrent on dis/connect. Then I eventually moved my qBittorrent setup to Linux and used the same script. If any of you want to use it let me know, and I will push it and paste the link.

Could you push it? I'd like to try it out.

@barkdoll
Copy link

Could you push it? I'd like to try it out.

You want the Ubuntu version or the Windows 10 version?

@trickinit
Copy link

trickinit commented Dec 20, 2018 via email

@barkdoll
Copy link

barkdoll commented Dec 20, 2018

@trickinit
Copy link

trickinit commented Dec 20, 2018 via email

@vtruong68
Copy link

Seems to still be an issue as of 11/27/19.

@FranciscoPombal FranciscoPombal added the Network Issues related to network connectivity label Feb 19, 2020
@ghost

This comment has been minimized.

@Forza-tng
Copy link

Forza-tng commented Jun 3, 2021

I'm still having this issue on Windows 10 with qbit 4.3.5.

In my case, the VPN local IP does not usually change between down-ups. The public IP can change.

The VPN is WireGuard, which implements a virtual network adapter, rather than using Windows VPN service.

It seems to me that a solution could be to use some kind of regular connectivity check to detect when the Public IP endpoint changes. qBittorrent already checks this during initial boot, so why not do it every 10 minutes (or by config option)?

image

image

Here is a snippet showing that I lost connection after dropping and starting wireguard at 2021-06-03T00:46:24. qBit didn't realise and I had to manually restart it.

(I) 2021-06-01T18:06:14 - Detected external IP: 98.128.186.117
(C) 2021-06-02T16:41:27 - Failed to listen on IP: 10.0.155.198, port: TCP/0. Reason: The requested address is not valid in its context
(C) 2021-06-03T00:46:20 - Failed to listen on IP: 10.0.155.198, port: TCP/0. Reason: The requested address is not valid in its context
(C) 2021-06-03T00:46:21 - Failed to listen on IP: 10.0.155.198, port: TCP/0. Reason: The requested address is not valid in its context
(C) 2021-06-03T00:46:21 - Failed to listen on IP: 10.0.155.198, port: TCP/0. Reason: The requested address is not valid in its context
(C) 2021-06-03T00:46:22 - Failed to listen on IP: 10.0.155.198, port: TCP/0. Reason: The requested address is not valid in its context
(I) 2021-06-03T00:46:24 - Successfully listening on IP: 10.0.155.198, port: TCP/50624
(I) 2021-06-03T00:46:24 - Successfully listening on IP: 10.0.155.198, port: UDP/50624
(I) 2021-06-03T18:06:55 - UPnP / NAT-PMP support [OFF]
(N) 2021-06-03T18:06:59 - qBittorrent v4.3.5 started
(N) 2021-06-03T18:06:59 - Using config directory: C:/Users/A L/AppData/Roaming/qBittorrent/
(N) 2021-06-03T18:29:52 - qBittorrent v4.3.5 started
(N) 2021-06-03T18:29:52 - Using config directory: C:/Users/A L/AppData/Roaming/qBittorrent/
(I) 2021-06-03T18:29:52 - Trying to listen on: 10.0.155.198:0
(N) 2021-06-03T18:29:52 - Peer ID: -qB4350-
(N) 2021-06-03T18:29:52 - HTTP User-Agent is 'qBittorrent/4.3.5'
(I) 2021-06-03T18:29:52 - DHT support [OFF]
(I) 2021-06-03T18:29:52 - Local Peer Discovery support [OFF]
(I) 2021-06-03T18:29:52 - PeX support [OFF]
(I) 2021-06-03T18:29:52 - Anonymous mode [OFF]
(I) 2021-06-03T18:29:52 - Encryption support [ON]
(N) 2021-06-03T18:29:52 - Using built-in Web UI.
(N) 2021-06-03T18:29:52 - Web UI translation for selected locale (en_GB) has been successfully loaded.
(N) 2021-06-03T18:29:52 - Web UI: Now listening on IP: 192.168.0.10, port: 8080
(N) 2021-06-03T18:29:52 - Options were saved successfully.
(I) 2021-06-03T18:29:52 - Successfully listening on IP: 10.0.155.198, port: TCP/50667
(I) 2021-06-03T18:29:52 - Successfully listening on IP: 10.0.155.198, port: UDP/50667
(N) 2021-06-03T18:29:52 - '...' restored.
(N) 2021-06-03T18:29:52 - '...' restored.
...
(I) 2021-06-03T18:55:20 - UPnP / NAT-PMP support [OFF]
(N) 2021-06-03T18:55:24 - qBittorrent v4.3.5 started
(N) 2021-06-03T18:55:24 - Using config directory: C:/Users/A L/AppData/Roaming/qBittorrent/
(I) 2021-06-03T18:55:24 - Trying to listen on: 10.0.155.198:0
(N) 2021-06-03T18:55:24 - Peer ID: -qB4350-
(N) 2021-06-03T18:55:24 - HTTP User-Agent is 'qBittorrent/4.3.5'
(I) 2021-06-03T18:55:24 - DHT support [OFF]
(I) 2021-06-03T18:55:24 - Local Peer Discovery support [OFF]
(I) 2021-06-03T18:55:24 - PeX support [OFF]
(I) 2021-06-03T18:55:24 - Anonymous mode [OFF]
(I) 2021-06-03T18:55:24 - Encryption support [ON]
(N) 2021-06-03T18:55:24 - Using built-in Web UI.
(N) 2021-06-03T18:55:24 - Web UI translation for selected locale (en_GB) has been successfully loaded.
(N) 2021-06-03T18:55:24 - Web UI: Now listening on IP: 192.168.0.10, port: 8080
(N) 2021-06-03T18:55:24 - Options were saved successfully.
(I) 2021-06-03T18:55:24 - Successfully listening on IP: 10.0.155.198, port: TCP/51298
(I) 2021-06-03T18:55:24 - Successfully listening on IP: 10.0.155.198, port: UDP/51298
(I) 2021-06-03T18:55:26 - Detected external IP: 98.128.186.72
(N) 2021-06-03T18:55:24 - '...' restored.
(N) 2021-06-03T18:55:24 - '...' restored.
...

@eqagunn
Copy link

eqagunn commented Aug 4, 2021

Still an issue. I have qBittorrent network interface set to VPN connection. Router restarts every night at 3 AM. VPN connection restarts after. qBittorrent drops and doesn't recover.

@sakkamade
Copy link

@eqagunn, #15253 (comment)

@eqagunn
Copy link

eqagunn commented Aug 4, 2021

@eqagunn, #15253 (comment)

@sakkamade Thanks. Tried to reproduce Tobias's solution but it doesn't work for me. After VPN restart qBitorrent still doesn't reconnect unless I restart it or switch between "All addresses" and "All IPv4 addresses".

@ghost
Copy link

ghost commented Aug 1, 2022

closing as duplicate of #12925
issue is tracked upstream as this is an upstream issue arvidn/libtorrent#4412

@ghost ghost closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2022
@cjom
Copy link

cjom commented Apr 11, 2024

I am sorry if it's not OK to resurrect this, but I want to share a way I found that is working great for me for over a week.

The other solutions also shared here don't work, for me, because:

  • Ping can fail to detect the network not having connection if it reconnects fast, unless you're pinging very very frequently, and I suppose the pinged sites might not enjoy that, neither I wish pinging so much.
  • Detecting IP changes also does not work (for me) because both my ISP and VPN not always change my assigned public IP.
  • And to make it worse, I also noticed that "/etc/init.d/qBittorrent.sh restart" many times did not fix the lack of connection.

Now I run a script that detects if the "dht_nodes" drop to zero and if it stays at zero for a bit then it fully stops qBitTorrent and starts it again.
This is a linux script, but could be easily ported to Windows:

#!/bin/sh
while true
do
  sleep 60
  # Get the cookies if did not before
  [ -f /tmp/.cookies.txt ] || curl -s -b /tmp/.cookies.txt -c /tmp/.cookies.txt --header 'Referer: http://127.0.0.1:YOURPORT' --data 'username=YOURUSERNAME&password=YOURPASSWORD' http://127.0.0.1:YOURPORT/api/v2/auth/login
  # Check if dht_nodes is zero every minute
  if [ "$(curl -s -b /tmp/.cookies.txt -c /tmp/.cookies.txt --header 'Referer: http://127.0.0.1:YOURPORT' http://127.0.0.1:YOURPORT/api/v2/transfer/info | jq '.dht_nodes')" -eq "0" ]
  then
    failcount=$((failcount+1))
  else
    failcount=0
  fi
  # If dht_nodes is zero for 5 minutes, restart qBitTorrent
  if [ $failcount -gt 5 ]
  then
    /etc/init.d/qBittorrent.sh stop
    sleep 20
    /etc/init.d/qBittorrent.sh start
  fi
done &

You need to install curl and jq, also edit YOURUSERNAME, YOURPASSWORD and YOURPORT to your case.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Network Issues related to network connectivity
Projects
None yet
Development

No branches or pull requests