Just prior to instantiating the web request, try adding the following line:
int tmp = ServicePointManager.DefaultConnectionLimit
This will force a load of the config files and should prevent the socket
from hanging. This 'type' of problem is a known issue with MS C# sockets.
If you haven't considered it already, I would suggest looking at the
TCPClient class. I had a similar issue and got around the problem with the
above solution.
Alex
"Nathan" <goo...@waitefamily.com> wrote in message
news:vn48ots...@corp.supernews.com...
Thanks for playing Jeopardy with me ;-) I put "int tmp =
ServicePointManager.DefaultConnectionLimit" at Line 2 in the code, but the
timeout error and POST body dump still occurred. I have the same feeling
you do: I'm going to have to rewrite this code using TCPClient. I did a
google group search for WebException Timeout and GetResponse() and got 69
hits. Over five of the responses from Microsoft's team stated issues with
bugs in .Net and their WebResponse class. Most of the bugs being different
issues too. .Net is showing it's youth. I'll start recoding it, but if you
or anyone else has any ideas, I'd love to hear 'em!
Thanks,
Nathan
"Trebek" <tre...@nospam.com> wrote in message
news:Itrcb.32008$uJ2....@fe3.columbus.rr.com...
Are you sure your Java code follows the specs for a valid HTTP 1.1
server? From RFC 2616:
"Requirements for HTTP/1.1 origin servers:
- Upon receiving a request which includes an Expect
request-header
field with the "100-continue" expectation, an origin server
MUST
either respond with 100 (Continue) status and continue to read
from the input stream, or respond with a final status code.
The
origin server MUST NOT wait for the request body before
sending
the 100 (Continue) response. If it responds with a final
status
code, it MAY close the transport connection or it MAY continue
to read and discard the rest of the request. It MUST NOT
perform the requested method if it returns a final status
code."
Under HTTP 1.1 (which is what the WebRequest is using), the data
does not have to be contained in the same HTTP message as the POST
command. The server must recognize that and send a "100 Continue"
status response. Obviously your server did not do that, thus the
logjam. Hope this helps shed some light on your problem. Good luck
with your HTTP server and client.
Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471433012.html
You just sold me on your book ;-) The Java server was the problem, as I was
implementing it using RFC 2068 and not the newer RFC 2616 which .NET
obviously uses. Hence, GetResponse was waiting for my Java server to send
it a "100 (Continue)" response before it would sent me the body. After
sending me the continue, the body proceeded just fine.
Thanks for your post!
Nathan
"Rich Blum" <rich...@juno.com> wrote in message
news:ccdac0da.03092...@posting.google.com...
For example say our your machine has the IP addresses:
11.11.11.2
11.11.11.3
11.11.11.4
Say you bind your service point request to 11.11.11.5
This will cause the GetResponse method to hang and use 100% of your CPU (If you had 4 cores/CPUs it might only use 100% of one of them so 25%)
MakeRequest()
{
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(requestUri);
webReq.ServicePoint.BindIPEndPointDelegate = this._bindIPEndPointDel;
webReq.Method = "GET";
// Hangs here on this line
HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
}
static BindIPEndPoint _bindIPEndPointDel = new BindIPEndPoint(BindIPEndPoint);
static IPEndPoint BindIPEndPoint(
ServicePoint servicePoint,
IPEndPoint remoteEndPoint,
int retryCount)
{
return new IPEndPoint(IPAddress.Parse("11.11.11.5"),0);
}
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com/g/