Repository: pymedusa/Medusa

Issue:
Rtorrent Not connecting
### Before submitting your issue:

Enable debug logging in Medusa settings, reproduce the error (be sure to disable after the bug is fixed)

**Branch/Commit:Main/latest
**OS:Ubuntu 16.x
**What you did: Attempted to connect my seedboxes rTorrent instance, doublechecked with seedbox company to confirm my information is correct
**What happened: "Could Not connect to rtorrent"
**What you expected: .... Connection to r torrent
**Logs:**
```
2017-09-06 14:43:36 DEBUG    SNATCHQUEUE-MANUALSNATCH-72218 :: [3f23fd2] Traceback (most recent call last):
  File "/opt/medusa/medusa/search/queue.py", line 487, in run
    self.success = snatch_episode(result)
  File "/opt/medusa/medusa/search/core.py", line 153, in snatch_episode
    result_downloaded = client.send_torrent(result)
  File "/opt/medusa/medusa/clients/torrent/generic.py", line 242, in send_torrent
    if not self._get_auth():
  File "/opt/medusa/medusa/clients/torrent/rtorrent_client.py", line 50, in _get_auth
    self.auth = RTorrent(self.host, self.username, self.password, True, tp_kwargs=tp_kwargs)
  File "/opt/medusa/lib/rtorrent/__init__.py", line 83, in __init__
    self._verify_conn()
  File "/opt/medusa/lib/rtorrent/__init__.py", line 122, in _verify_conn
    assert "system.client_version" in self._get_rpc_methods(
  File "/opt/medusa/lib/rtorrent/__init__.py", line 161, in _get_rpc_methods
    return(self._rpc_methods or self._update_rpc_methods())
  File "/opt/medusa/lib/rtorrent/__init__.py", line 150, in _update_rpc_methods
    self._rpc_methods = self._get_conn().system.listMethods()
  File "/usr/lib/python2.7/xmlrpclib.py", line 1243, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1602, in __request
    verbose=self.__verbose
  File "/opt/medusa/lib/rtorrent/lib/xmlrpc/requests_transport.py", line 150, in request
    response.headers)
ProtocolError: <ProtocolError for http://nl4727.dediseedbox.com//rutorrent/plugins/httprpc/action.php: 401 Client Error: Unauthorized for url: http://nl4727.dediseedbox.com//rutorrent/plugins/httprpc/action.php Traceback (most recent call last):
  File "/opt/medusa/lib/rtorrent/lib/xmlrpc/requests_transport.py", line 145, in request
    response.raise_for_status()
  File "/opt/medusa/lib/requests/models.py", line 844, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 401 Client Error: Unauthorized for url: http://nl4727.dediseedbox.com//rutorrent/plugins/httprpc/action.php
```
Side Note, this does work with couchpotato


Discussion:
Just for sake of being thorough, this is couchpotato:
![image](https://user-images.githubusercontent.com/1373128/30129068-b93a876e-9312-11e7-8364-f36c4ca654dd.png)

Ist the double slash intentional?
```http://nl4727.dediseedbox.com//rutorrent/plugins/httprpc/action.php```
no, i double checked and will provide screenshots in a minute that, that is
not what is entered, it is a single slash

On Sep 6, 2017 3:01 PM, "Dario" <notifications@github.com> wrote:

> Ist the double slash intentional?
> http://nl4727.dediseedbox.com//rutorrent/plugins/httprpc/action.php
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/pymedusa/Medusa/issues/3084#issuecomment-327582275>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABTzyLsxKK80JgJUziuQ20a3zLFTCNFaks5sfuwcgaJpZM4POzqi>
> .
>

No need, I have no reason to not believe you. Can you try with https instead of http? If that doesn't work either, I would say it currently only works with scgi (as that is what I currently use myself).
I am told that it won't work but I suspect it would give you a different error, log below

 File "/opt/medusa/medusa/search/queue.py", line 487, in run
    self.success = snatch_episode(result)
  File "/opt/medusa/medusa/search/core.py", line 153, in snatch_episode
    result_downloaded = client.send_torrent(result)
  File "/opt/medusa/medusa/clients/torrent/generic.py", line 242, in send_torrent
    if not self._get_auth():
  File "/opt/medusa/medusa/clients/torrent/rtorrent_client.py", line 50, in _get_auth
    self.auth = RTorrent(self.host, self.username, self.password, True, tp_kwargs=tp_kwargs)
  File "/opt/medusa/lib/rtorrent/__init__.py", line 83, in __init__
    self._verify_conn()
  File "/opt/medusa/lib/rtorrent/__init__.py", line 122, in _verify_conn
    assert "system.client_version" in self._get_rpc_methods(
  File "/opt/medusa/lib/rtorrent/__init__.py", line 161, in _get_rpc_methods
    return(self._rpc_methods or self._update_rpc_methods())
  File "/opt/medusa/lib/rtorrent/__init__.py", line 150, in _update_rpc_methods
    self._rpc_methods = self._get_conn().system.listMethods()
  File "/usr/lib/python2.7/xmlrpclib.py", line 1243, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1602, in __request
    verbose=self.__verbose
  File "/opt/medusa/lib/rtorrent/lib/xmlrpc/requests_transport.py", line 150, in request
    response.headers)
ProtocolError: <ProtocolError for https://nl4727.dediseedbox.com//rutorrent/plugins/httprpc/action.php: 401 Client Error: Unauthorized for url: https://nl4727.dediseedbox.com//rutorrent/plugins/httprpc/action.php Traceback (most recent call last):
  File "/opt/medusa/lib/rtorrent/lib/xmlrpc/requests_transport.py", line 145, in request
    response.raise_for_status()
  File "/opt/medusa/lib/requests/models.py", line 844, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 401 Client Error: Unauthorized for url: https://nl4727.dediseedbox.com//rutorrent/plugins/httprpc/action.php
Curious, only for my information because I do have a workaround. Would this be something that would be fixed? Again, no worries if it isn't, I know its free and open source, so fixing this would not be a major priority. I just want to know so I can set my instance to work.
Of course, if it is a confirmed bug (seems like it) it will be fixed ASAP. Just keep in mind that all devs are volunteers and right now most, if not all, of us are still on vacation.
Understood, Just wanted to check in :)
@is33 
Sorry for the extremely late reply.
I successfully tested this setting on my config and it works just fine here.

This is how my config looks like:
![image](https://snapr.pw/i/159f8b3606.png)

You have Basic Authentication enabled, right? 
Dont worry about it. I know you guys are super busy :)
yes i did. and did double check everything. I provided logs earlier and its
(medusa) adding another '/'

On Sep 30, 2017 9:48 AM, "Dario" <notifications@github.com> wrote:

@is33 <https://github.com/is33>
Sorry for the extremely late reply.
I successfully tested this setting on my config and it works just fine here.

This is how my config looks like:
[image: image]
<https://camo.githubusercontent.com/f05dbeec61c8158e13bbff87d814d8c9d5ea6fec/68747470733a2f2f736e6170722e70772f692f313539663862333630362e706e67>

You have Basic Authentication enabled, right?

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
<https://github.com/pymedusa/Medusa/issues/3084#issuecomment-333309742>,
or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABTzyOiZU5ZrD7_GaHhnx0IDD-1fvPBJks5snka4gaJpZM4POzqi>
.

~Turns out that's not the issue, it just appears like that in the logs, but the request is actually done without the double slash. Are you sure that you are using the correct credentials (try to login with them within the browser)? Is the auth method really "Basic" or "Digest" (in your couchpotato screenshot you are using "Digest")? Can you please post a screenshot of your settings like I did above?~

Nvm, found the issue - pushing a fix soon.

Resolving patch:
diff --git a/lib/rtorrent/lib/xmlrpc/requests_transport.py b/lib/rtorrent/lib/xmlrpc/requests_transport.py
--- a/lib/rtorrent/lib/xmlrpc/requests_transport.py
+++ b/lib/rtorrent/lib/xmlrpc/requests_transport.py
@@ -110,9 +110,9 @@ def request(self, host, handler, request_body, verbose=0):
         # Need to be done because the schema(http or https) is lost in
         # xmlrpc.Transport's init.
         if self._use_https:
-            url = "https://{host}/{handler}".format(host=host, handler=handler)
+            url = "https://{host}{handler}".format(host=host, handler=handler)
         else:
-            url = "http://{host}/{handler}".format(host=host, handler=handler)
+            url = "http://{host}{handler}".format(host=host, handler=handler)
 
         # TODO Construct kwargs query instead
         try:


Test patch: