Error: ConnectionError: Connection Reset by Peer
Issue
While running the fivetran debug command, the following error appears:
requests.exceptions.ConnectionError: ('Connection aborted.',
ConnectionResetError(104, 'Connection reset by peer'))
Environment
Fivetran Connector SDK
Resolution
To resolve this issue, use the pycurl library for API calls instead of the requests library. You can do that by following these steps:
Install the
pycurllibrary:pip install pycurlIn your Python code, replace API calls that use
requestswith ones that usepycurl.Reset and test you connector again:
fivetran reset fivetran debug
By switching to pycurl, you gain more direct control over connection parameters, which helps to avoid the connection reset issues encountered.
Cause
This issue can occur due to several potential causes:
Connection handling: The
requestslibrary andpycurlhandle connections differently:- requests uses a higher-level abstraction with automatic connection pooling
pycurluses the lower-levellibcurllibrary, which provides more robust connection handling
User-Agent headers: The default User-Agent differs between
pycurlandrequestslibraries, which can affect how certain API endpoints respondTLS/SSL Handshake:
pycurluses the system's SSL libraries directly, which can better handle certain TLS negotiation scenarios.