G
Guest
Hello,
I have a web application which uses multiple threads to connect to a couple
of other web servers. All works very well, except occasionally when the load
is a bit heavy, I start getting errors on my connect method. I don't believe
the error is coming from the servers I connect to, since I have gotten the
errors from both servers at different times, and both are not related to each
other in any way (different vendors). I always retry my request a few
seconds later, and all works fine the 2nd or 3rd time around.
I've worked on this problem for months now, it's driving me nuts! Any help
would be so greatly appreciated.
The errors I get vary, but it's always one of the following:
- The operation has timed-out
- The underlying connection was closed: The request was canceled
- (occasionnally, but not often) Object reference not set to an instance of
an object
- Non-negative number required. Parameter name: byteCount
Looking up on various newsgroups, I find many others who experience the same
issues (ie: http://www.dotnet247.com/247reference/msgs/30/152007.aspx)
Unfortunately, I haven't found a resoltuion as of yet. Microsoft KB
mentions something about it, but I guess I'd have to pay for the support...
(http://support.microsoft.com/default.aspx?scid=kb;en-us;819450)
I have attached my connect method below (in C#). Thanks again for any help!
private HttpWebResponse connect(string url, string variables)
{
StreamWriter myWriter = null;
HttpWebRequest objRequest = null;
HttpWebResponse response = null;
try
{
objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = variables.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
objRequest.KeepAlive = false;
objRequest.Proxy = GlobalProxySelection.GetEmptyWebProxy();
objRequest.Timeout = VOLT_TIMEOUT_MILLISECONDS;
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(variables);
myWriter.Close();
response = (HttpWebResponse)objRequest.GetResponse();
}
catch (ThreadAbortException)
{
if (response != null)
response.Close();
Thread.ResetAbort();
}
catch (Exception ex)
{
if (response != null)
response.Close();
throw new Exception("Exception occurred in VoltDelta.connect(" + url + ",
" + variables + "): " + ex.Message);
}
return response;
}
I have a web application which uses multiple threads to connect to a couple
of other web servers. All works very well, except occasionally when the load
is a bit heavy, I start getting errors on my connect method. I don't believe
the error is coming from the servers I connect to, since I have gotten the
errors from both servers at different times, and both are not related to each
other in any way (different vendors). I always retry my request a few
seconds later, and all works fine the 2nd or 3rd time around.
I've worked on this problem for months now, it's driving me nuts! Any help
would be so greatly appreciated.
The errors I get vary, but it's always one of the following:
- The operation has timed-out
- The underlying connection was closed: The request was canceled
- (occasionnally, but not often) Object reference not set to an instance of
an object
- Non-negative number required. Parameter name: byteCount
Looking up on various newsgroups, I find many others who experience the same
issues (ie: http://www.dotnet247.com/247reference/msgs/30/152007.aspx)
Unfortunately, I haven't found a resoltuion as of yet. Microsoft KB
mentions something about it, but I guess I'd have to pay for the support...
(http://support.microsoft.com/default.aspx?scid=kb;en-us;819450)
I have attached my connect method below (in C#). Thanks again for any help!
private HttpWebResponse connect(string url, string variables)
{
StreamWriter myWriter = null;
HttpWebRequest objRequest = null;
HttpWebResponse response = null;
try
{
objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = variables.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
objRequest.KeepAlive = false;
objRequest.Proxy = GlobalProxySelection.GetEmptyWebProxy();
objRequest.Timeout = VOLT_TIMEOUT_MILLISECONDS;
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(variables);
myWriter.Close();
response = (HttpWebResponse)objRequest.GetResponse();
}
catch (ThreadAbortException)
{
if (response != null)
response.Close();
Thread.ResetAbort();
}
catch (Exception ex)
{
if (response != null)
response.Close();
throw new Exception("Exception occurred in VoltDelta.connect(" + url + ",
" + variables + "): " + ex.Message);
}
return response;
}