internal static Boolean getAllProjectInfo(List<ProjectInfo> list)
{
try
{
WebClient client = new WebClient();
client.Credentials = new NetworkCredential(ConArgs.USER_NAME, ConArgs.USER_PASSWORD);
var projects = XDocument.Parse(client.DownloadString(ConArgs.TP_URL + string.Format("/api/v1/Projects/?take=1000")));
//add conditions of the parent node to avoid cases that there are "Project" nodes under the parent "Project" node
IEnumerable<XElement> category_projects = from p in projects.Descendants("Project") where p.Parent.Name.ToString() == "Projects" select p;
foreach (XElement item in category_projects)
{
ProjectInfo pi = new ProjectInfo();
pi.Id=Convert.ToInt32(item.Attribute("Id").Value);
pi.Name=item.Attribute("Name").Value;
list.Add(pi);
}
return true;
}
catch (WebException ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
=================================================
When looking at the exception caught, the message of inner exception shows: "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host", and the message of the exception shows "The underlying connection was closed: An unexpected error occurred on a send". Please refer to the enclosed screen capture for reference.
The error code is 10054, which I checked from MSDN is:
- WSAECONNRESET
- 10054
| - Connection reset by peer.
An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket). This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.
|
I have verified the USER_NAME and the USER_PASSWORD, should be correct. And have verified the Web request using the web-browser and postman tool from Google, the return result is of no problem.
Do you have any ideas what the problem may be?
Best regards,
Ken