Following this thread, https://stackoverflow.com/a/2582070/6534818, I am wondering if there is any room for improvement to my REST API query that would limit the frequency to which I receive the following error: "An existing connection was forcibly closed by the remote host"
. The thread suggests, as one possibility, that the query is malformed.
My general setup for a query to Azure DevOps is as follows:
# Access Token
pat = "secret_token_here"
# authorization encoding
authorization = str(base64.b64encode(bytes(":" pat, "ascii")), "ascii")
# url
url = "https://dev.azure.com/org/project/"
# REST headers
headers = {"Accept": "application/json", "Authorization": "Basic " authorization}
# GET
response = requests.get(
url=(url "_apis/wit/workItems/%s/revisions?api-version=6.0" % str(work_item)),
headers=headers,
)
I tend to suffer this issue when running this in a loop, perhaps every 4th or 5th total run, looking up each item of interest.
CodePudding user response:
There can be many reasons for the issue:
- The network link between server and client may be temporarily going down.
- running out of system resources.
- sending malformed data.
To examine the problem in detail, you can use Wireshark.
or you can just re-request or re-connect again.
You can check this Article to know the cause for this error in various platforms, along with a resolution and also this SO Thread.