Note that there are some explanatory texts on larger screens.

plurals
  1. POC# HttpWebRequest.GetResponse() hangs when requesting a method of Azure web role
    primarykey
    data
    text
    <p>I'm writing code to send a request to my web service in windows azure, and it turned out I cannot get response until timeout. What's confusing is that i'm sure everything inside my service has been done, and yet the response did not come back.</p> <p>My service code looks like this:</p> <pre><code>public virtual JsonResult ServiceMethod() { // 1. do the work // 2. write something to database return Json(result, JsonRequestBehavior.AllowGet); } </code></pre> <p>And my client code looks like this:</p> <pre><code>HttpWebRequest webRequest = WebRequest.Create(new Uri(httpAddress)) as HttpWebRequest; webRequest.Timeout = 1000 * 1000; webRequest.ServicePoint.ConnectionLeaseTimeout = 40 * 60 * 1000; webRequest.ServicePoint.MaxIdleTime = 40 * 60 * 1000; webRequest.ServicePoint.SetTcpKeepAlive(true, 50 * 1000, 1000); webRequest.Method = "GET"; using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse) { // handle the response } </code></pre> <p>Now I'm pretty sure my code in my service has completed because i tried to write something to database and that happened. I also checked the iis log on the virtual machine where the service is hosted and it showed http 200 is returned. But the call GetResponse() in my client code hanged until the 1000 seconds timeout is reached.</p> <h2>Update</h2> <p>There is a parameter to my web API which will affect how long the method runs.(I didn't show it in the above code for simplicity). If the service method runs for sufficiently long time (like 6 or 7 minutes), then the hanging problem will happen. Otherwise, the web response can successfully return. So i guess there might be some problem within the timeout setting. But there are several timeout properties in the HttpWebRequest and its base classes, i don't know what combination of them can result in or solve this problem.</p> <p>Any ideas of what can the problem be? Thanks a lot.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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