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

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 _make_request
self._validate_conn(conn)
File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connectionpool.py", line 994, in validate_conn
conn.connect()
File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connection.py", line 394, in connect
ssl_context=context,
File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\util\ssl
.py", line 370, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "D:\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
session=session
File "D:\Programs\Python\Python37\lib\ssl.py", line 853, in _create
self.do_handshake()
File "D:\Programs\Python\Python37\lib\ssl.py", line 1117, in do_handshake
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.exc_info()[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.with_traceback(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 _make_request
self._validate_conn(conn)
File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connectionpool.py", line 994, in validate_conn
conn.connect()
File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\connection.py", line 394, in connect
ssl_context=context,
File "C:\Users\john.wang\Documents\project\GenesysExtract\pythonCode\urllib3\util\ssl
.py", line 370, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "D:\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
session=session
File "D:\Programs\Python\Python37\lib\ssl.py", line 853, in _create
self.do_handshake()
File "D:\Programs\Python\Python37\lib\ssl.py", line 1117, in do_handshake
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
response = requests.post("https://login.mypurecloud.com/oauth/token", data=request_body, headers=request_headers)
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:

client_id = "myId"
client_secret = "MyKey"

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

request_headers = {
"Authorization": f"Basic {authorization}",
"Content-Type": "application/x-www-form-urlencoded"
}
request_body = {
"grant_type": "client_credentials"
}

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

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

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

response_json = response.json()

requestHeaders = {
"Authorization": f"{response_json['token_type']} {response_json['access_token']}"
}

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