S
Steve Binney
I am having a problem with timeouts and a growing number of connections. My
app periodically (every second) makes a Request and reads a response.
The code for HttpWebRequest is as follows:
sendReq = (HttpWebRequest)WebRequest.Create(myUri);
sendReq.Method = "PUT";
Stream tempStream = sendReq.GetRequestStream();
tempStream.Write(PostData,0,PostData.Length);
tempStream.Close();
respReq = (HttpWebRequest)WebRequest.Create(myUri);
HttpWebResponse response = (HttpWebResponse)respReq.GetResponse();
Stream receiveStream = response.GetResponseStream();
receiveStream.Close();
readStream.Close();
response.Close();
When I make repeasted requests, it works OK for a while but eventually I get
timeouts on GetResponse. In TCPView, I can see a two new connections every
time I make a new request. The number of connections continually grows.
If I force garbage collection, the old connects are cleaned up and the app
works better. With occaisional timeouts
How do I keep reusing the connections without forcing GC ? I am closing
the streams and response as the docs indicate.
Steve
app periodically (every second) makes a Request and reads a response.
The code for HttpWebRequest is as follows:
sendReq = (HttpWebRequest)WebRequest.Create(myUri);
sendReq.Method = "PUT";
Stream tempStream = sendReq.GetRequestStream();
tempStream.Write(PostData,0,PostData.Length);
tempStream.Close();
respReq = (HttpWebRequest)WebRequest.Create(myUri);
HttpWebResponse response = (HttpWebResponse)respReq.GetResponse();
Stream receiveStream = response.GetResponseStream();
receiveStream.Close();
readStream.Close();
response.Close();
When I make repeasted requests, it works OK for a while but eventually I get
timeouts on GetResponse. In TCPView, I can see a two new connections every
time I make a new request. The number of connections continually grows.
If I force garbage collection, the old connects are cleaned up and the app
works better. With occaisional timeouts
How do I keep reusing the connections without forcing GC ? I am closing
the streams and response as the docs indicate.
Steve