views:

202

answers:

1

I've got a Browser Helper Object written in C# that makes a HTTPWebRequest POST to my server when the user clicks a button on a windows form, and in the normal case this works great. However, every so often, I'll get a BHO that seems to go crazy and continually send me a huge number of HTTPWebRequests (around 50 to 100 per minute). The only way I've been able to stop the behavior to have the client reboot their PC, often the users have even closed IE, but the POSTs keep rolling in.

Has anyone ever seen a similar behavior when using HTTPWebRequest? It almost seems like some retry logic in the connection is going crazy, but I didn't think HTTPWebRequest had any retry mechanism built in, so that seems very unlikely.

I'm setting up my connection incorrectly and is there a good strategy for preventing something like this?

Here is how I'm setting up my connection:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(myUrl);
webRequest.Timeout = 30000;
webRequest.Method = "POST";
webRequest.KeepAlive = false;
System.Net.ServicePointManager.Expect100Continue = false;
webRequest.ContentType = "text/xml";
webRequest.ContentLength = myData.Length;

using (StreamWriter requestWriter = new StreamWriter(webRequest.GetRequestStream()))
{
    requestWriter.Write(this.myData);
    requestWriter.Close();
}
A: 

Can you have the client get a wireshark trace from his PC when this happens?

Could there be some other object that is hosting the IE control, which in turn causes your BHO to be hosted and start triggering the requests?

Unfortunately, unless you can get a repro on your machine, it will just be a shot in the dark.

feroze
Interesting idea, unfortunately haven't been able to get this thing to repro. I'll have to do some thinking about what would host the IE control on an average users's desktop..
Millhouse
Try double- or triple-clicking the submit button. Many users don't "get" the distinctions between double-click targets and single-clickers (links, buttons, shortcut icons, etc.). I can't think exactly what, but there might be *something* hosing things when a 2nd identical request is attempted before the 1st has completed.
Jay
That is something to try, I supposed disabling the button in the click handler until I'm sure my request has completed would guard against that condition as well.
Millhouse