Problem with Httpwebresponse. Does not answer

Asked

Viewed 209 times

1

I hope you can help me, I have a problem when I try to see make a request on my server ( the request is slow, takes about 10 minutes to be processed and returned )

For quick requests everything works normal, for slow requests ( more than 10 minutes ) c# does not identify that there was a response from http server.

The strange thing is that the same code on the server if decreased the loop works, so the problem is the c# because I identify in the database that the entire http server cycle has been completed and returned

Code:

        Request = (HttpWebRequest) HttpWebRequest.Create( url );
        Request.Method = "get";
        Request.AllowAutoRedirect = false;
        Request.CookieContainer = Cookie;
        Request.KeepAlive = false;
        Request.ContentLength = 0;
        Request.Timeout = 20 * ( 1000 * 60 ); // minutos
        Request.ReadWriteTimeout = 20 * ( 1000 * 60 ); // minutos
        Request.Proxy = null;

        HttpWebResponse Response = (HttpWebResponse) Request.GetResponse();
        Stream ResponseStream = Response.GetResponseStream();
        StreamReader ResponseReader = new StreamReader( ResponseStream );

        bufferResponse = ResponseReader.ReadToEnd();

        Response.Close();
        ResponseStream.Close();
        ResponseReader.Close();

        return ( bufferResponse );

I’ve tried using the commands:

ServicePointManager.DefaultConnectionLimit = 10;
ServicePointManager.Expect100Continue = false;

And they didn’t help.

  • Which address are you applying to?

  • Good afternoon partner. It’s a server of its own, but I did a test on it to see if it really was in c# the problem and it is yes. When I use the code : Sleep(10); echo "OK"; It returns OK in c# after 10 seconds, but if I do Sleep(900); echo "OK"; c# does not respond even after 15 minutes

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.