qbittorrent / qBittorrent

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

qBittorrent autostarts before network interface is ready, causing no connectivity #21681

Open sofa-singer opened 1 day ago

sofa-singer commented 1 day ago

qBittorrent & operating system versions

qBittorrent: 5.0.0 Operating system: Debian GNU/Linux 12 (bookworm) Qt: 6.4.2

What is the problem?

This was never a problem on 4.x, but since updating to 5.0 every time I restart my Pi and QB launches it has no network connectivity.

The log shows "The configured network interface is invalid. Interface: "tun0"".

To fix it I have to manually change the network interface to something else, save, then change it back again.

Steps to reproduce

  1. Restart system, QBT will auto start.
  2. Open WebUI, all torrents will be stalled, firewall icon at bottom of screen says "Connection Status: Disconnected".
  3. Open settings, change network interface from tun0 to anything else, save.
  4. Change back to tun0, save.
  5. Everything works.

Additional context

No response

Log(s) & preferences file(s)

(N) 2024-10-24T13:58:40 - qBittorrent v5.0.0 started. Process ID: 963 (N) 2024-10-24T13:58:40 - Using config directory: /home/pi/.config/qBittorrent (C) 2024-10-24T13:58:40 - The configured network interface is invalid. Interface: "tun0" (N) 2024-10-24T13:58:40 - Trying to listen on the following list of IP addresses: "tun0:64904" (I) 2024-10-24T13:58:40 - Peer ID: "-qB5000-" (I) 2024-10-24T13:58:40 - HTTP User-Agent: "qBittorrent/5.0.0" (I) 2024-10-24T13:58:40 - Distributed Hash Table (DHT) support: ON (I) 2024-10-24T13:58:40 - Local Peer Discovery support: ON (I) 2024-10-24T13:58:40 - Peer Exchange (PeX) support: ON (I) 2024-10-24T13:58:40 - Anonymous mode: OFF (I) 2024-10-24T13:58:40 - Encryption support: ON (I) 2024-10-24T13:58:40 - UPnP/NAT-PMP support: ON

sofa-singer commented 1 day ago

I may have posted prematurely, but I found a workaround which was to add these line into the autostart service file:

[Unit] BindsTo=sys-devices-virtual-net-tun0.device After=sys-devices-virtual-net-tun0.device

HanabishiRecca commented 1 day ago

The default systemd service does wait for network.

https://github.com/qbittorrent/qBittorrent/blob/c080fc3aa09400d7bfdecf73ad5fb409e02a8110/dist/unix/systemd/qbittorrent-nox%40.service.in#L4-L5

So it's up for the system to do it right.

Also, you could add something like

After=systemd-networkd-wait-online.service

or

After=NetworkManager-wait-online.service

depending on a particular network managing daemon you use.

I also would recommend you to create a drop-in override instead of editing the service file directly.