python-qBittorrent
python-qBittorrent copied to clipboard
error(104, 'Connection reset by peer')
i'm running qbittorrent in a box along with couchpotato (a movies pvr). the box is running xubuntu 16.04. i have never worked with python but apparently couchpotato uses your module to talk to qbittorrent's api. everytime it tries to retrieve the list of torrents and their status, it gets error(104, 'Connection reset by peer'). it doesn't happen when there are just a few torrents in the client, but right now i have +500 of them and it has been over +1000. any input?
This is potato's error log: [.downloaders.qbittorrent_] Failed to get status from qBittorrent: ('Connection aborted.', error(104, 'Connection reset by peer'))
Hey David,
Can you if you are able to connect to qBittorrent directly using this library instead of going through CP server? Are you able to browse qBittorrent's official web interface for torrents using your browser without having any connection issues?
On Tue, Feb 14, 2017 at 7:52 PM, David Cabrera [email protected] wrote:
i'm running qbittorrent in a box along with couchpotato (a movies pvr). the box is running xubuntu 16.04. i have never worked with python but apparently couchpotato uses your module to talk to qbittorrent's api. everytime it tries to retrieve the list of torrents and their status, it gets error(104, 'Connection reset by peer'). it doesn't happen when there are just a few torrents in the client, but right now i have +500 of them and it has been over +1000. any input?
This is potato's error log: [.downloaders.qbittorrent_] Failed to get status from qBittorrent: ('Connection aborted.', error(104, 'Connection reset by peer'))
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/v1k45/python-qBittorrent/issues/17, or mute the thread https://github.com/notifications/unsubscribe-auth/AHgzfY6EgXt5jt23ZWBpWXgfucBXsdYAks5rcbi4gaJpZM4MAiAd .
1. No.
It would clear out CP as the possible culprit. But sincerely, it looks to me that the problem is in the API. CP is sending you the same keys regardless of how many torrents there are active, yet, the error is produced only with a great deal of them (it seems to me). Also, their log is giving me the error traceback to your methods.
I know it is a pity, but I have never worked with python and I understand very little of its ecosystem. I did understand that you are giving out a class with a method that takes a set of keys and values that you use to build your HTTP request and forward it to the WebUI. It filters through the torrents and has a callback waiting. It seems to me that on their side they are just sending the label. They pull that from the configuration variables or in its defect, from the default "couchpotato" label.
I read a little through your code thinking naively that it could be that qBittorrent is expecting a "category" key and CP was calling it "label", but it seems to me that your own API is aware of that problem and corrects it before submitting.
2. Yes.
The Web UI is up. Also, it receives with no problem the requests to add torrents.
Note: Another issue that I don't know if is in your side or CP's, but I feel it's ok to give the heads up, the torrents are not getting deleted upon completion.
I did understand that you are giving out a class with a method that takes a set of keys and values that you use to build your HTTP request and forward it to the WebUI.
Yes, this library just provides a python API on top of the WEB API provided by qBittorrent
I read a little through your code thinking naively that it could be that qBittorrent is expecting a "category" key and CP was calling it "label", but it seems to me that your own API is aware of that problem and corrects it before submitting.
Yes, qBittorrent recently changed the label key to category key without any deprecation warnings and the change is not consistent, some endpoints work with the label key and some with the category key.
CP maintains its own version of this lib on its repository here. And they updated it long ago. This is why I asked if you are able to view the torrents with this library alone, I am not trying to blame anyone here :)
I never used this lib with more than 30 active torrents running on qBittorrent and reproducing this bug will require me to add at least 500 torrents in my client and it would take good amount of time. It would be very helpful if you try can see reproduce this using the library alone. You can read the docs, you should be able to set it up and test it within 10-15 minutes.
Yes, I checked CP's version of your API and noticed that they even have it with a different class name. And also I pondered the fact that you probably have no way of testing this problem. Since I have never worked with python, I'll do this: I will wait until the torrents are downloaded fully, they should in less than a week. Keep trying from CP's interface, and see if the problem disappears with a lower amount of torrents.
If not, It could maybe be a good reason to take my first baby steps into python. Thanks anyways. I will come back and keep you posted in any case.
Anyways... I'm gonna drop this here in case you want to look at it: https://couchpota.to/forum/viewtopic.php?f=3&t=51392&p=79451#p79451
I replied to that thread so that we can investigate further.
If you want to test if you can reproduce this issue, you can follow the following steps:
- Create a file named
qbtest.pywith the following code:
from qbittorrent import Client
qb = Client('http://127.0.0.1:8080/')
qb.login('admin', 'your-secret-password')
# defaults to admin:admin.
# to use defaults, just do qb.login()
torrents = qb.torrents()
print len(torrents)
- Run the following commands on your terminal
$ sudo apt-get install python-pip
$ sudo pip install python-qbittorrent
$ python qbtest.py
This should print the number of torrents you have running in you client. Let me know what output you see.
This is my output, as you see, it fails intermittently.
sysadmin@slavesrv:/$ python ~/qbtest.py
540
sysadmin@slavesrv:/$ python ~/qbtest.py
540
sysadmin@slavesrv:/$ python ~/qbtest.py
Traceback (most recent call last):
File "/home/sysadmin/qbtest.py", line 9, in <module>
torrents = qb.torrents()
File "/usr/local/lib/python2.7/dist-packages/qbittorrent/client.py", line 169, in torrents
return self._get('query/torrents', params=params)
File "/usr/local/lib/python2.7/dist-packages/qbittorrent/client.py", line 44, in _get
return self._request(endpoint, 'get', **kwargs)
File "/usr/local/lib/python2.7/dist-packages/qbittorrent/client.py", line 76, in _request
request = rq.get(final_url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 501, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 473, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))
sysadmin@slavesrv:/$ python ~/qbtest.py
540
sysadmin@slavesrv:/$ python ~/qbtest.py
540
sysadmin@slavesrv:/$ python ~/qbtest.py
540
sysadmin@slavesrv:/$ python ~/qbtest.py
540
sysadmin@slavesrv:/$ python ~/qbtest.py
^[[ATraceback (most recent call last):
File "/home/sysadmin/qbtest.py", line 9, in <module>
torrents = qb.torrents()
File "/usr/local/lib/python2.7/dist-packages/qbittorrent/client.py", line 169, in torrents
return self._get('query/torrents', params=params)
File "/usr/local/lib/python2.7/dist-packages/qbittorrent/client.py", line 44, in _get
return self._request(endpoint, 'get', **kwargs)
File "/usr/local/lib/python2.7/dist-packages/qbittorrent/client.py", line 76, in _request
request = rq.get(final_url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 501, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 473, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))
sysadmin@slavesrv:/$ python ~/qbtest.py
540
Look, I have the frontend of qBittorrent accesible from outside. If you need to run testing and you want to have a proper scenario with +500 torrents, I'm willing to have setup some temporary password and give you access. Then you can query it from outside. Let me know if that is OK with you. I can even bring it up to a +1000 torrents if you want a more intense setup.
Okay, I tried to lookup the cause of this problem and found this. This error is raised when the connection is reset/closed by the client itself.
You can setup a temporary account for me and email me the credentials if you comfortable with it. I'll try to test it by this sunday.
Will do. Funny enough, this would probably signal something to you, I changed the url that CP is using to query qB to the outside name that I have, and it is working fine now. Also tested it with your snippet, and it works. Some timing issue? No clue.
If changing the local URL to a public URL fixes the problem then I don't think I'll be able to reproduce the issue unless I do the same setup on my local machine (i.e. adding more than 500 torrents).
I'll keep this issue open for few weeks and if everything goes okay, I'll assume that it was an issue related to python itself. And the workaround/fix towards it is using public url instead of local url.
Stale issue message