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

bind ip address to network interface seems to require restart if ip address has been changed #6495

Closed
Sopor opened this issue Mar 9, 2017 · 16 comments
Labels
Network Issues related to network connectivity

Comments

@Sopor
Copy link

Sopor commented Mar 9, 2017

In the advanced settings i can bind qBT to my network interface instead of my IP address and that sounds like a very good idea but even if the optional IP address is set to 'All addresses' it still require a restart of qBT if my IP address has been changed. I'm aware that both settings require restart but for me that is if i change the settings and not if the IP address get changed. If this require a restart then i can't find any use of this feature. So i wondering if something is wrong or this need to be fixed?

qBT 3.3.10
Windows 7

@WhosAsking
Copy link

IINM, this is a fundamental issue of an Internet-using server like qBittorrent (peer-to-peer programs are both client and server). One of the first things the program has to do is declare to the TCP/IP stack that it is listening: a process known as binding. That involves telling it which interfaces/addresses and ports it is using. In order to change something this fundamental, it has to release the bind and then re-bind, but that means peers and so on have to find you again. All in all, it can get pretty complicated, thus why it's left for something to be done the next time it starts up.

@brainchild0
Copy link

@WhosAsking I am afraid I don't understand your objection to releasing the previous bindings, then rebinding under a new IP address, in the case that the previously used interface or local address becomes unavailable. Is it strictly a question of design complexity, or do you believe that such a change would result in unwanted behavior?

I suggest that preserving the previous peer connections should not be a driving consideration, because as the original report correctly indicates, once a particular local address is lost and replaced with a new one, not only is it impossible to maintain the previous connections, but the overall feature has limited usefulness unless the application attempts to make new connections using the new address.

Broadly, then, the application should maintain connections over one interface and address at a time, and certain events should cause it to break connections over and unbind from a previous address, and begin again with a new one. Do you agree with this suggestion, and if not, would you please offer your reasoning?

@hdcTenBasePid
Copy link

Two bits worth, I tend to agree with @brainchild0 .

@hdcTenBasePid
Copy link

hdcTenBasePid commented Feb 28, 2018

qBitTorrentx64/v4.0.4, Windows 10x64 Home, 1709 16299.192

OK, as far as I can tell it's fixed with v4.04, not a 100% with v4.0.3.

In my testing I can now start qBitTorrent with:

  1. No internet connection, then connect and qBt will only use the interface selected. If 'Any Interface' or a 'Named Interface' is the connection then qBt connects, no restart.

  2. After (1) connect to a VPN. qBt will now connect to the 'Named Interface'^ for that VPN, change the interface if necessary (Options->Advanced, Network Interface), without needing a restart.

  3. After (2) disconnect from the VPN^^ application and use another VPN^^^ application and service. Change the 'Named Interface' to the new VPN and qBt connects without a restart.

  4. Terminate VPN and Network connection and redo either (1) or (2) and qBt connects with no restart required.

  5. With no 'Named Interface' connection available there is no libtorrent interface leakage.

I believe that's the functionality we all wanted on the torrent side. Great work team!

#7235, #7540, #7892, #8258

Not sure if this is a worry but:

  • the Python Search engine is not restricted to 'Named Interface', bind to interface still exposes searches #3116
  • nor is the Add Torrent fetch metadata Dialog from that search.
  • No Tracker or Torrent activity occurs if Start Torrent is checked and OK pressed to that dialog.

^ You would not use 'Any Interface' whilst using a VPN, unless it's application had an in-built Firewall.
^^ OpenVPN TAP based.
^^^ Proprietary App TAP based with Firewall.

@senposage
Copy link

senposage commented Mar 2, 2018

fullstop: folks jumping the gun here a bit
I can still reproduce the issue here on 4.0.4

remember you need to have both the interface AND the ip set in the options for the binding to work correctly

if you just set the ip it will use your public IP until the vpn is up. which defeats the point of binding
( I don't know why it does this qbt should not be changing any user defined settings if the ip is not valid it should use it anyway and then wait for the interface to become valid)

now if your only connection is though the vpn this isn't a problem if its not and e.g you want to start the vpn on demand for torrent tasks it still doesn't detect the interface state change correctly

@senposage
Copy link

senposage commented Mar 2, 2018

if you set the interface to the TAP adapter it does indeed come up when the vpn comes online. however it still displays RED incoming connection state and still complains about in the log also takes a good 30 seconds to come up

3/2/2018 12:26 AM - qBittorrent failed listening on interface vpn.ip.here.0 port: TCP/4242. Reason: The requested address is not valid in its context.

@senposage
Copy link

I uploaded a video of the issue in-action make sure to pay attention to what I am saying in the video particularly the bit about bind to IP's scope not being limited to the selected interface which I think part of the issue there and qbit continuing to use the public ip interface even after the vpn is established

https://youtu.be/X_pq_oBi8a4

@Dodgexander
Copy link

Just wanted to add that I still have this problem also in 4.04.

I am binding to my virtual network adaptor for my VPN, but as soon as I change IP in my VPN software qBitorrent requires a restart for it connect to trackers.

A good way to see if its working or not is to test a known working torrent with lots of trackers.

Once you change the ip of the binded VPN interface all those trackers will gradually appear as not working and in the message field you get the message: "the requested address is not valid in its context".

@ngosang ngosang added the Network Issues related to network connectivity label Sep 16, 2018
@Sopor
Copy link
Author

Sopor commented Oct 17, 2018

I'm running 4.1.2 and i still have the same issue. Nothing has been changed. If i get a new IP address i need to restart qBT.

@UIEa4z7odDF9Xpl3
Copy link

Just repeating Sopor for v4.1.5, same issue. My VPN provider has decided to start changing my IP several times a day, connection stays live, qBT is bound to its interface, All IP Addresses, but all torrents cease until I restart the qBT.

@jafo5236
Copy link

jafo5236 commented Feb 12, 2019

Check out this app I found. https://github.com/dynamichael/qConnectionSitter It watches the network interface for disconnect/reconnect and restarts qBittorrent when the connection is re-established.

Having this built into qBittorrent would be the best solution, but this has resolved the issue of having to manually restart qBittorrent every time my VPN disconnects/reconnects.

@senposage
Copy link

bumping this, this is getting tiresome maby target for 5.0 ?

@Marenz
Copy link

Marenz commented May 14, 2019

I can confirm this issue and would love a fix

@bazg177
Copy link

bazg177 commented Feb 16, 2020

I wrote a script to re-bind qBittorrent to a specified interface, it updates the config and restarts qBittorent if your IP has changed. See here: https://github.com/bazg177/qBittorrent-binder/blob/master/qBittorrent-binder.bat

@ghost
Copy link

ghost commented May 4, 2022

I think this was fixed in 4.2.x since it supports Interface/IP address changes without requiring a restart.

@ghost ghost closed this as completed May 4, 2022
@bazg177
Copy link

bazg177 commented May 4, 2022

Great, will check this out

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

No branches or pull requests