Error when using webrequest

I came across a strange error. My application has to unity3d module that connects to a web service using WebRequest. When I start in debug mode MonoDevelop(with attach to Unity3d) and my application try send the second request i get the following error:

System.Net.WebException: The request timed out
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
  at FooClient.Services.WebHttpClient.Execute (FooClient.Services.BaseRequest r) [0x00000] in <filename unknown>:0 
  at FooClient.BL.RequestClient.ProcessRequest (FooClient.Services.BaseRequest r) [0x00000] in <filename unknown>:0 

First and third request web service are working normally
If I run the application without debugging, then everything works fine.

Here is the code request method

  protected override RequestResponse Execute(BaseRequest r)
            string url = string.Format("{0}{1}/{2}", _serverUrl, r.Service.ToLower(), r.Action.ToLower());
            if (r.Params != null && r.Params.Count > 0)
                url = url + "?";
                url = url + string.Join("&", r.Params.Where(c => c.Value != null).Select(c =>
                    c.Name + "=" + _encoder.Encode(c.Value.ToString())

            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            // Set some reasonable limits on resources used by this request
            request.MaximumAutomaticRedirections = 4;
            request.MaximumResponseHeadersLength = 4;
            request.Accept = "application/xml";
            request.ContentType = "application/xml";
            request.Timeout = 10000;
            request.KeepAlive = false;

            request.CookieContainer = new CookieContainer();
            request.CookieContainer.Add(new Uri(url), new Cookie("Aspect", _context.ScreenAspect));


            // Set credentials to use for this request.
            request.Credentials = CredentialCache.DefaultCredentials;

            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)

                // Get the stream associated with the response.
                using (Stream receiveStream  = response.GetResponseStream())


                    // Pipes the stream to a higher level stream reader with the required encoding format. 
                    using (var readStream = new StreamReader(receiveStream, Encoding.UTF8))

                        string result = readStream.ReadToEnd();


                        return new RequestResponse
                            StatusCode = response.StatusCode,
                            Content = result


Please submit a bug report following these guidelines:

This appears to have been fixed in Unity 4.5.4f1. I had been using 4.5.3f3 and after upgrading to 4.5.4f1 I no longer have the issue. I believe it is related to this line in the release notes of 4.5.4:

  • Scripting: Fixed the debugger causing waits to be interrupted.