Last post Dec 18, 2013 01:13 AM by prashant.singh243
Dec 17, 2013 05:17 AM|prashant.singh243|LINK
We are sending http request to one of GDS (TravelPort's WorldSpan). In normal condition it's woking fine, but in case of meta search request (Here request comes in bulk), after sometime (around 180 request) our system stops sending request to GDS.
When we change the default configurations to ServicePointManager.DefaultConnectionLimit = 1000;, then we got about 1140 responses. But again it stopped sending requests thereafter.
Here is the code for your reference:
private HttpWebRequest CreateRequestObject()
HttpWebRequest serverRequest = (HttpWebRequest)WebRequest.Create(this.Uri);
// We are posting a XML request
serverRequest.Method = "POST";
serverRequest.ContentType = "text/xml";
// Set up the connection to optimize for web services and receive compressed responses.
ServicePointManager.UseNagleAlgorithm = false;
ServicePointManager.Expect100Continue = false;
serverRequest.AutomaticDecompression = DecompressionMethods.GZip;
// Always add authentication to the header - avoids issue with internal URL's that doesn't require
byte authBytes = Encoding.UTF8.GetBytes((this.UserName + ":" + this.Password).ToCharArray());
serverRequest.Headers["Authorization"] = "Basic " + Convert.ToBase64String(authBytes);
Dec 17, 2013 06:46 AM|AidyF|LINK
The service you are contacting will be having a problem with the load rather than it being anything in your code. Chances are they will need to fix things their end, but you could maybe try a Threading.CurrentThread.Sleep operation to pause for a few hundreds
of a second after each request to ease the load.
Dec 17, 2013 10:45 PM|Steven Cheng - MSFT|LINK
For client-side code, besides the HttpWebRequest creation code you provided, have you properly closed the WebResponse object after you finished the request (and retrieved the response data)? Also, as AidyF mentioned, you should also check if the problem
occurs at the server-side. Try using fiddler or wireshark to inspect the HTTP traffic from your client app to the server to see when the problem occurs, is the request correctly sent out from the client machine (and pending on response from server-side).
Dec 18, 2013 01:13 AM|prashant.singh243|LINK
Thanks a lot, my problem has been solved.