Help please, I am experiencing an error message "The underlying connection was closed: An unexpected error occurred on a send." connecting to a cloud base RESTFUL API. It is working in staging and development server but not on production server.
My codes written in c#:
Declared in configuration file
public static string HttpGet(string url, string accessToken, string username)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.KeepAlive = false;
request.ContentLength = 0;
request.Timeout = 100000
request.Headers.Add("accessToken", accessToken);
request.Headers.Add("username", username);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string result = null;
try
{
if (response.StatusCode.ToString().ToLower() == "ok")
{
string contentType = response.ContentType;
Stream content = response.GetResponseStream();
if (content != null)
{
StreamReader contentReader = new StreamReader(content);
result = contentReader.ReadToEnd();
}
}
}
Madan ShekarPosted May 15, 2018, 5:21 AM
Madan ShekarPosted May 15, 2018, 5:20 AM