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

Automatically fix qBittorrent listening socket errors #6

Closed
Aldaviva opened this issue Jul 11, 2024 · 2 comments
Closed

Automatically fix qBittorrent listening socket errors #6

Aldaviva opened this issue Jul 11, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@Aldaviva
Copy link
Owner

Aldaviva commented Jul 11, 2024

Problem

Every once in a while, qBittorrent randomly gets itself wedged and halts all traffic until you either restart the program or change the listening port. When this happens, the status bar health icon is a red globe (instead of green) and the log shows the following message (repeated several times):

7/10/2024 2:11 p - Failed to listen on IP. IP: "XXX.XXX.XXX.XXX". Port: "TCP/53708". Reason: "The requested address is not valid in its context"

Proposed solution

  1. Periodically check if qBittorrent is running
  2. If it's running, poll the web API to get the connection status. The connection_status key can have values connected, firewalled, and disconnected.
    GET http://localhost:8080/api/v2/transfer/info HTTP/1.1
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "connection_status": "connected",
        "dht_nodes": 288,
        "dl_info_data": 119417236972,
        "dl_info_speed": 23819,
        "dl_rate_limit": 0,
        "up_info_data": 16199052905,
        "up_info_speed": 748749,
        "up_rate_limit": 0
    }
  3. If the connection status is not connected, change the listening port to a different value, then change it back to the correct value.
@Aldaviva Aldaviva added the enhancement New feature or request label Jul 11, 2024
@Aldaviva Aldaviva self-assigned this Jul 11, 2024
@Aldaviva
Copy link
Owner Author

Aldaviva commented Aug 3, 2024

Every 3 minutes, PortForwardingService will check if qBittorrent is running and, if so, its connection status. If it's running and the connection status is not connected, it will temporarily change the qBittorrent listening port to 1 above the current PIA forwarded port, then to the correct PIA forwarded port again.

@Aldaviva
Copy link
Owner Author

This actually worked.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant