cpoppema / docker-flexget

An auto updating FlexGet container.
82 stars 39 forks source link

No Sock5 Proxy Support #20

Closed Noki closed 6 years ago

Noki commented 6 years ago

Hi!

Great docker container! This helped me a lot. However I would love to see the dependencies for socks5. Currently I always get the following error message:

Unable to download the RSS for task Exampletask (https://example.com/): Missing dependencies for SOCKS support.

Best regards Tobias

cpoppema commented 6 years ago

Hello @Noki, thanks for this.

Can you provide a bit more details on how you're using socks5 ? I'm not really familar with it. If you tell me how you have set it up, I can use that to work out what exactly is missing dependencies for SOCKS support and what the dependencies are and make sure it works properly.

Noki commented 6 years ago

I want to use a socks5 proxy for the requests in the flexget config:

proxy: socks5://10.10.10.1:9150

I did not get it to work but I tried to install the following:

pip install -U requests[socks]
pip install -U urllib3[socks]
pip install -U PySocks

I'm kind of stuck here because I don't really understand if it should be enough to run this in the container or if I need to actually need to rebuild the container image to test this properly. I just started playing around with containers on my NAS.

cpoppema commented 6 years ago

If I add that line for proxy at the root-level to my yml-file, Flexget reports:

CRITICIAL               [/] The key `proxy` is not valid here.

I still don't know how I would need to set it up, according to https://flexget.com/Plugins/proxy this seems the way to go.

Noki commented 6 years ago

It works if you add it as part of a task:

tasks:
  Movies:
    proxy: socks5://10.10.10.1:9150
    rss: "https://example.com/feed.rss"
    ...
cpoppema commented 6 years ago

Thanks! I now indeed see the same error.

It seems like you were almost there. I believe the last thing you need to do is to restart your docker container. Running pip install -U urllib3[socks] makes the SOCKSProxyManager available in this code from the requests library:

try:
    from urllib3.contrib.socks import SOCKSProxyManager
except ImportError:
    def SOCKSProxyManager(*args, **kwargs):
        raise InvalidSchema("Missing dependencies for SOCKS support.")

Since Python caches imports, as long as Flexget is running in daemon-mode, it will keep using the stubbed SOCKSProxyManager (since importing SOCKSProxyManager from this module technically worked). Restarting the Flexget daemon by restarting the container should let next first import succeed and you should have full socks5 support.

Let me know if this helps, so I can officially include it as a dependency in the docker image.

After restarting, instead of Missing dependencies for SOCKS support., I got a simple timeout error.

Noki commented 6 years ago

Works now! Thanks a lot!