Click here to Skip to main content
14,983,300 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i request Api more then one time, Httpwebrequest or page timeout request Failure takes.If i run script in local no issues take place But in Live Server Timeout issues happens in more than one request. (our live server works in ISS 7, weather the Issue take due this)

below is the code i'm using

for (int i = this.cartDetail.Count - 1; i >= 0; i--)
                   //// Call api submit order using multiple thread
                   this.threads[i] = new Thread(new ThreadStart(this.APISubmitOrder));
                   this.threads[i].Name = i.ToString(new AcctNumberFormat());
                   this.threads[i].CurrentCulture = CultureInfo.CurrentCulture;
                   this.threads[i].CurrentUICulture = CultureInfo.CurrentUICulture;
               for (int i = this.cartDetail.Count - 1; i >= 0; i--)
                   //// join all thread

       private void APISubmitOrder()
             myHttpWebRequest = (HttpWebRequest)WebRequest.Create(strAPIURL);
             //// Encode the Post Data
             byte[] data = ASCIIEncoding.UTF8.GetBytes(strPostData.ToString());
             myHttpWebRequest.Method = "POST";
             myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
             myHttpWebRequest.ContentLength = data.Length;
             myHttpWebRequest.KeepAlive = false;
             myHttpWebRequest.Timeout = 110000;
             strmrdRequest = myHttpWebRequest.GetRequestStream();
            ////Send the Data
            strmrdRequest.Write(data, 0, data.Length);
            //// Get the http response
            myHttpResponse = myHttpWebRequest.GetResponse();
            //// Get response stream
            strReadResponse = new StreamReader(myHttpResponse.GetResponseStream());
           //// parse response
           string strReadResponseContent = strReadResponse.ReadToEnd();
       in webconfig
        <httpRuntime maxRequestLength="1024" enable="true" executionTimeout="50000" />

Any help would be appreciated. If you need any more information or a more clear explanation, please do not hesitate to ask.

I think somehow the request is not terminating properly. If you do it locally you would get the reply instantly as localhost takes very less time to reply.[^]
Abhishek Sur 22-Sep-10 15:40pm
thank for reply Abhishek Sur I terminated httpwerequest using
but still having same problem - john8182
Abhishek Sur 22-Sep-10 15:42pm
I think please enable line by line logging on your server code, and see if the server is actually called or not.

If you see that the server is called but still the issue, you might recreate the server code to cure the issue.
hey buddy at one time you can send max to httpRequest to cannot
send more than 2 request to server. This restriction is due to security issue. once your 2 request served than n than you can send more request to server.

so try to send max 2 request at a time. n check d output :-)

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