Aug 10, 2009 at 8:49 PM
Edited Aug 10, 2009 at 8:49 PM
I haven't been diagnosing the issue so much as observing it .. but it happens fairly regularly (a steady flow of calls can usually reproduce the error within an hour).
While the error can certainly occur when _bytesLeft = 0, I've also seen it happen where
_byesLeft > 0 but offset > _bytesLeft, so the
_bytesLeft - offset value becomes negative and causes the same issue.
I know at least in most cases, the temp string containing the request buffer has contained my entire requst (I don't have a req body, only headers)... which makes me wonder why it would think there are still 200/300+ bytes left to read (when there obviously
Just now while letting things run, I encountered another exception in OnReceive at line 245:
string temp = Encoding.ASCII.GetString(_buffer, 0, _bytesLeft);
In this case, _bytesLeft was -206 and as you might expect, caused an exception.
My test application is simply using the C# HttpWebRequest class to make sequential (single threaded) requests to the web server.
I haven't dug very deep into this code but I suspect there _bytesLeft (which seems to be linked to both the exception I've seen) isn't being properly reset/updated in all cases.