Note that there are some explanatory texts on larger screens.

plurals
  1. POHttpWebRequest stops working suddenly, No response received after few requests
    text
    copied!<p>I’m working with a WPF .net 4.0 Application. I have a search bar. For each search token I need to do 8 http request to 8 separate URLs to get search results. I send 8 requests to server after 400 milliseconds once the user stops typing in search bar. Searching for 6 to 7 search-tokens results comes very nicely. But after that suddenly HttpWebRequest stops working silently. No exception was thrown, no response was received. I'm working with Windows 7, I disabled the firewall too. I don't know where the subsequent http requests are lost.</p> <p>Can anyone show me lights to fix this issue? </p> <p>Below is my code for HttpWebRequest call.</p> <pre><code>public static void SendReq(string url) { // Create a new HttpWebRequest object. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = "application/x-www-form-urlencoded"; request.Proxy = new WebProxy("192.168.1.1", 8000); // Set the Method property to 'POST' to post data to the URI. request.Method = "POST"; // start the asynchronous operation request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request); } private static void GetRequestStreamCallback(IAsyncResult asynchronousResult) { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; // End the operation Stream postStream = request.EndGetRequestStream(asynchronousResult); string postData = this.PostData; // Convert the string into a byte array. byte[] byteArray = Encoding.UTF8.GetBytes(postData); // Write to the request stream. postStream.Write(byteArray, 0, byteArray.Length); postStream.Close(); // Start the asynchronous operation to get the response request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request); } private static void GetResponseCallback(IAsyncResult asynchronousResult) { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; // End the operation using(HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult)) { using(Stream streamResponse = response.GetResponseStream()) { using(StreamReader streamRead = new StreamReader(streamResponse)) { string responseString = streamRead.ReadToEnd(); Debug.WriteLine(responseString); } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload