I have the following method:
public static WorkItem GetWorkItem(int workItemId, bool relations)
{
Uri accountUri = new Uri(URL);
string personalAccessToken = PERSONAL_ACCESS_TOKEN;
VssConnection connection = new VssConnection(accountUri, new VssBasicCredential(string.Empty,
personalAccessToken));
var client = connection.GetClient<WorkItemTrackingHttpClient>();
WorkItemExpand? expand = relations ? WorkItemExpand.Relations : (WorkItemExpand?)null;
return client.GetWorkItemAsync(workItemId, null, null, expand).Result;
}
Basically I am using the Microsoft.TeamFoundationServer.Client nuget package to get a workitem from our companies Azure Devops project.
Most of the time this method works fine, however occasionally (Meaning once in every five or so attempts) the client.GetWorkItemAsync() method will fail with the error:
Message:"One or more errors occurred. (The SSL connection could not be established, see inner exception.)"
Source:"System.Private.CoreLib"
InnerException:
{
Message:"Authentication failed because the remote party has closed the transport stream."
Source:"System.Net.Security"
InnerException:null
}
This has only started occuring after I updated my project from targeting Dot Net Core 2.1 to Dot Net Core 3.1
My question is what can I do to solve this issue? Is this an problem with Microsoft's Microsoft.TeamFoundationServer.Client nuget package, or am I doing something wrong?
As a temporary solution I seem to be able to simply repeatedly call the method until it works but I would rather not have to do that.
Any help is appreciated, Thanks.
EDIT:
To further test this issue I downgraded my project from Dot Net Core 3.1 to Dot Net Core 2.1 and ran the method 10 times and it never threw any error. No code changes. Then, I upgraded my project from Dot Net Core 2.1 back to Dot Net Core 3.1 and ran the method. I Immediately got this error again.
Unless I am missing something, I can only conclude somehow the Dot Net Core change has broken this method.