W
Wilfried Mestdagh [MapPoint MVP]
Hello,
I do a HTTP POST in a thread with following code (only relevant copied here):
Cli cli = new Cli();
Thread cliThread = new Thread(new ThreadStart(cli.Run));
cliThread.Start();
the Cli class is like this:
public void Run()
{
HttpWebResponse webResponse;
try {
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
req.Timeout = timeout; // set to 10 seconds
req.Method = "POST";
StreamWriter stOut = new StreamWriter(req.GetRequestStream(),
System.Text.Encoding.Default);
stOut.Write(xml);
stOut.Close();
webResponse = (HttpWebResponse)req.GetResponse();
statuscode = (int)webResponse.StatusCode;
StreamReader stIn = new StreamReader(webResponse.GetResponseStream());
string response = stIn.ReadToEnd();
stIn.Close();
} catch (WebException webEx) {
This works fine with one thread. But when I do several requests in parallel
then I get webexception "the operation timed out". I checked with a tool (a
kind of proxy that log all TCP traffic) and the server is giving immediatly a
200 and a page for "each" POST. So the data is received every time. But wy is
the timeout generated?
Can someone advice here?
I do a HTTP POST in a thread with following code (only relevant copied here):
Cli cli = new Cli();
Thread cliThread = new Thread(new ThreadStart(cli.Run));
cliThread.Start();
the Cli class is like this:
public void Run()
{
HttpWebResponse webResponse;
try {
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
req.Timeout = timeout; // set to 10 seconds
req.Method = "POST";
StreamWriter stOut = new StreamWriter(req.GetRequestStream(),
System.Text.Encoding.Default);
stOut.Write(xml);
stOut.Close();
webResponse = (HttpWebResponse)req.GetResponse();
statuscode = (int)webResponse.StatusCode;
StreamReader stIn = new StreamReader(webResponse.GetResponseStream());
string response = stIn.ReadToEnd();
stIn.Close();
} catch (WebException webEx) {
This works fine with one thread. But when I do several requests in parallel
then I get webexception "the operation timed out". I checked with a tool (a
kind of proxy that log all TCP traffic) and the server is giving immediatly a
200 and a page for "each" POST. So the data is received every time. But wy is
the timeout generated?
Can someone advice here?