-
Notifications
You must be signed in to change notification settings - Fork 55
ConnectionResetError: [Errno 104] Connection reset by peer #491
Comments
Have you tried to put a |
I have tried to put |
News about the error. The error only happens if there is a big time gap between the calls to couchdb. |
In my case, the gap between the requests is ~ 410s |
If you are leaving connections idle longer than the server will keep them alive you need to disable HTTP keep-alive or handle the error and then retry the request. You can probably disable the HTTP keep-alive by Another option would be to configure your server/proxy to keep connections alive for longer. |
How can I know if I am leaving connections idle? I though that the python-cloudant or request would manage these kind of behaviours automatically. |
@mojito317 I could fix it! The error was happening because the server was killing our connection. To avoid it, we need to add the following header on the client.py, as you suggested. What do you think of a PR to add a param on CouchDB class to allow the user decide if he want to put the header or not? |
I think there is no need to do that, since the import os
from cloudant.client import Cloudant
client = Cloudant(os.environ['SERVER_USERNAME'], os.environ['SERVER_PASSWORD'], url=os.environ['SERVER_URL'], connect=True)
# you can set this way:
client.r_session.headers.update({'Connection': 'close'}) Edit: I double-checked it, and the |
Ty @mojito317 . |
Bug Description
We are using the cloudant-python lib to handle our connections with our database. Randomly the code raises a ConnectionResetError.
1. Steps to reproduce and the simplest code sample possible to demonstrate the issue
I could not create a external scenario to reproduce it, but I will outline the context of the error scenario.
I have an code that make iterative calls to our couchdb. Every loop make the same call to an specific view, but with different keys.
Sometimes, the request is not sent and the program return the error below.
At the first I thought that could be something related with our proxy - Haproxy. But, I have tested the script connecting directly with the database and the error continued. On the next, without the HAPROXY, I replaced the request call (from the python-cloudant) to a simple request (from request package) and the error disappeared, so I think that the error is related with this lib. In addition, my couchdb server does not log any request call, so, its is one more info that suggest that the error is on the client side.
2. What you expected to happen
The script should make the requests and finish without any error.
3. What actually happened
Eventually in some requests the script raise the error below.
Environment details
The text was updated successfully, but these errors were encountered: