Legacy Dev Forum Posts

 View Only

Sign Up

[WinError 10054] An existing connection was forcibly closed by the remote host

  • 1.  [WinError 10054] An existing connection was forcibly closed by the remote host

    Posted 06-05-2025 19:20

    John_Wang | 2019-10-29 21:16:35 UTC | #1

    Hello,,

    My code was working fine for a while after massive recordings data pull , around 50k conversations' recording data download.

    After this my job was throttled and the job was put on retry for 6 hours. 6 hours later it starting download again, but one recording files download hung for 10 minute (which will be killed and restarted by my master process).

    But Eventually my session was kicked out by pure cloud server (I guess) . and now i want to restart my data pulling script but I could not connect anymore ,it error out at get authorization with "[WinError 10054] An existing connection was forcibly closed by the remote host",

    Is it possible that Pure cloud blocked my IP because of my suspicious behavior? or is because of my previous job didn't terminated gracefully? or something else?

    at the same time I am still able to run same code from the other computer.

    any suggestions are appreciated! thanks!

    here is full trace info: Traceback (most recent call last): File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connectionpool.py", line 672, in urlopen chunked=chunked, File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connectionpool.py", line 376, in makerequest self.validateconn(conn) File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connectionpool.py", line 994, in validateconn conn.connect() File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connection.py", line 394, in connect sslcontext=context, File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\util\ssl.py", line 370, in sslwrapsocket return context.wrapsocket(sock, serverhostname=serverhostname) File "D:\Programs\Python\Python37\lib\ssl.py", line 412, in wrapsocket session=session File "D:\Programs\Python\Python37\lib\ssl.py", line 853, in create self.dohandshake() File "D:\Programs\Python\Python37\lib\ssl.py", line 1117, in dohandshake self.sslobj.do_handshake() ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\requests\adapters.py", line 449, in send timeout=timeout File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connectionpool.py", line 720, in urlopen method, url, error=e, _pool=self, stacktrace=sys.excinfo()[2] File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\util\retry.py", line 400, in increment raise six.reraise(type(error), error, stacktrace) File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\packages\six.py", line 734, in reraise raise value.withtraceback(tb) File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connectionpool.py", line 672, in urlopen chunked=chunked, File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connectionpool.py", line 376, in makerequest self.validateconn(conn) File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connectionpool.py", line 994, in validateconn conn.connect() File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connection.py", line 394, in connect sslcontext=context, File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\util\ssl.py", line 370, in sslwrapsocket return context.wrapsocket(sock, serverhostname=serverhostname) File "D:\Programs\Python\Python37\lib\ssl.py", line 412, in wrapsocket session=session File "D:\Programs\Python\Python37\lib\ssl.py", line 853, in create self.dohandshake() File "D:\Programs\Python\Python37\lib\ssl.py", line 1117, in dohandshake self.sslobj.do_handshake() urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "test.py", line 41, in <module> response = requests.post("https://login.mypurecloud.com/oauth/token", data=requestbody, headers=requestheaders) File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\requests\api.py", line 116, in post return request('post', url, data=data, json=json, *kwargs) File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\requests\api.py", line 60, in request return session.request(method=method, url=url, *kwargs) File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\requests\sessions.py", line 533, in request resp = self.send(prep, *send_kwargs) File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\requests\sessions.py", line 646, in send r = adapter.send(request, *kwargs) File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\requests\adapters.py", line 498, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

    here is my code to get authencation:

    clientid = "myId" clientsecret = "MyKey"

    authorization = base64.b64encode(bytes(clientid + ":" + clientsecret, "ISO-8859-1")).decode("ascii")

    requestheaders = { "Authorization": f"Basic {authorization}", "Content-Type": "application/x-www-form-urlencoded" } requestbody = { "granttype": "clientcredentials" }

    response = requests.post("https://login.mypurecloud.com/oauth/token", data=requestbody, headers=requestheaders)

    if response.statuscode == 200: logging.info("Got token") else: logging.error(f"Failure: {str(response.statuscode)} - {response.reason}")

    accesstoken = response.json()["accesstoken"]

    response_json = response.json()

    requestHeaders = { "Authorization": f"{responsejson['tokentype']} {responsejson['accesstoken']}" }


    system | 2019-11-28 21:10:30 UTC | #2

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 6353