Click here to Skip to main content
15,906,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created one C# web service where
1. First i finds no of pages for that date range
2. After that in Loop I made Page request after 3rd request i Got 524 Error

private string postPaymentRequestToGateway(String queryUrl, String urlParam)
{

String message = "";
StreamWriter myWriter = null;// it will open a http connection with provided url
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
WebRequest objRequest = WebRequest.Create(queryUrl);//send data using objxmlhttp object
WriteToFile("Request Time Before Response " + System.DateTime.Now);
objRequest.Method = "POST";
try
{
objRequest.ContentType = "application/x-www-form-urlencoded";//to set content type
myWriter = new System.IO.StreamWriter(objRequest.GetRequestStream());
myWriter.Write(urlParam);//send data
myWriter.Close();//closed the myWriter objec=-[ TR

// Getting Response
//using (System.Net.HttpWebResponse objResponse = (System.Net.HttpWebResponse)objRequest.GetResponse())
using (WebResponse objResponse = objRequest.GetResponse())
//receive the responce from objxmlhttp object
{
//Thread.Sleep(10000);
WriteToFile("Request Time After Response " + System.DateTime.Now);
using (System.IO.StreamReader sr = new System.IO.StreamReader(objResponse.GetResponseStream()))
{
message = sr.ReadToEnd();
sr.Close();
}
//WriteToFile("Request Time After Response Message " + message);
}

}

catch (Exception exception)
{

WriteToFile("Inner Exception Stack" + exception.StackTrace);
WriteToFile("Inner Exception " + exception.InnerException.Message);
}
finally
{
objRequest.Abort();

myWriter.Close();//closed the myWriter object//05April2019

}
return message;

}

What I have tried:

For this I added objRequest.Abort(); in finally method
I tried various options but I Cant find solution .
Error in objRequest.GetResponse()) where Response takes more time after third pages
and then timeout error .
Can anyone tell me how to resolve this problem?.......
Posted
Updated 29-Dec-19 20:16pm

The error code 524 can signify a time out error, which means the server is unable to satisfy your request. You need to talk to the providers of the API.
 
Share this answer
 
Comments
suresh shewale 30-Dec-19 0:51am    
is the error related to only API Provider?....Is there any alternative ?As API Provider provider gives response for single page request very well.....
Hello
I have resolved my problem
What i have done is
I increased execution time in web.config for web service where i deployed my service.
<httpruntime executiontimeout="1000">

This resolves my problem
and Thanks Richards.....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900