By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,696 Members | 1,522 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,696 IT Pros & Developers. It's quick & easy.

HttpWebRequest idling NullReferenceException

P: n/a
I'm using the HttpWebRequest repeatidly. I have basic authentication, unsafe connection pooling, keepalive, and preauthentication on. Within .NET it clearly reuses the http connections, I can easily verify this is correct with a packet sniffer. I may make 1000s of requests over 1-2 established http connections in a given time period.

Then the application sits idling for a while, until the user is ready to something. The next attempt to hit the server fails. The request is running the exact same code as the first time, there is no state being held around from the first time, when calling the HttpWebRequest.GetResponse() I receive a NullReferenceException (object not set to an instance of an object...), and get no call stack or location information which leads me to believe its on some secondary thread/deep in the .NET implementation.

in any case, I'm sure this has been seen by others, and some solution/workaround/stupid thing I may be doing is out there, a point in the right direction would be great. again, theres no problem with making the requests (GET & POST several times), its just when it idles for a while, and I can only assume that the remote server kills the keepalive connections, but .NET doesn't know this and tries to reuse them anyway internally.
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Should also say that after it fails, the next attempt to request something from that site succeeds. Again, I'm assumming that .NET internals realize the keep alive connection it had is no longer valid, and throws it away when it fails, so next time it just creates a new http connection

but I could be totally off, ass out of me and myself.
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.