xitation / protonvpn-deluge-gluetun-portforward

A docker-compose and script to setup Deluge and Gluetun with Wireguard via ProtonVPN with Port Forwarding
7 stars 1 forks source link

Deluge API caches requests so listen port is never updated #2

Open RogueOneEcho opened 1 month ago

RogueOneEcho commented 1 month ago

First, thanks for putting together this guide its been incredibly useful. While getting it setup myself I came some alternative approaches that other users may want to consider.

I haven't confirmed this with your setup but I suspect it's the case...

If the web client is not connected to the daemon (which it won't be on startup until you manually connect in the UI) then the core.set_config request will return a response {"result": null, "error": {"message": "Unknown method", "code": 2}, "id": 1} and the listen port is not set.

The core.set_config request is being sent every minute by configure_port.sh.

https://github.com/xitation/protonvpn-deluge-gluetun-portforward/blob/aeb287cef2a2fb03df55f2c86884f9759324116b/scripts/configure_port.sh#L22

However, deluge cache's requests and will return the same response without updating the config. So, even after you manually connect the daemon in the UI the script will still fail to set the listen port.

The solution to this is to either increment the id, or just use a random integer:

'{"method": "core.set_config", "params": [{"listen_ports": ['$FORWARDED_PORT','$FORWARDED_PORT']}], "id": '${RANDOM}'}'
xitation commented 1 month ago

Good find!

Will look at updating this sometime later next week, or if you chuck me a PR I can look / test / merge that.

Appreciate the contributions, I hadn't ever expected anyone to pay much attention to this :)

RogueOneEcho commented 1 month ago

For reference here's my full script which also addresses #3

https://gist.github.com/RogueOneEcho/9994851203d1bdce7f455ed3430cf4a2

RogueOneEcho commented 1 month ago

It should also be possible to automatically connect to the web client to the daemon to avoid the necessity of doing so manually but I've not looked into that yet: https://deluge.readthedocs.io/en/latest/devguide/how-to/curl-jsonrpc.html#get-list-of-deluged-hosts https://deluge.readthedocs.io/en/latest/devguide/how-to/curl-jsonrpc.html#connect-to-deluged-host

RogueOneEcho commented 1 month ago

FYI I've documented my full setup here: https://github.com/RogueOneEcho/how-to-setup-deluge-with-protonvpn-portforward

It's quite a deviation from your guide so I won't create a PR but you're welcome to pick out anything

xitation commented 1 month ago

I like the look of your setup, I might just update my repo to indicate that your fork is the way to go and direct people that way, if you are ok with that?

RogueOneEcho commented 1 month ago

Sure, you can add a link to mine, but I wouldn't remove any of the content from yours as it's still useful to follow it for a more direct setup. I suspect the length of my guide might deter some people.