General Network Error in .Net Framework 1.1

Under some circumstances (such as with certain network bandwidth), you might get a general network error in .Net Framework 1.1 when executing a query that takes longer than SqlCommand.CommandTimeout value.

This has something to do with how SqlClient 1.1 deals with timeout. Basically we track the timeout value by decrementing it each time after we make a net library read() call. And it’s possible that the value goes underflow. Since we always cast the timeout value to a UInt16 before passing it to the net library read() call, if it happens to be -1, we’ll pass in a UInt16.MaxValue. In the net library read() call, a timeout with UInt16.MaxValue has special meaning: return immediately. If no packet is received, a general network error (GNE) will get thrown.

Fixing the problem will have some unintentional effects on every other customer. Queries that are succeeding today, due to the above timeout logic, might begin failing.

The temporary workaround is to change packet size to a smaller one so that the read() call could have enough time to read a packet before hitting the return immediately case. The ultimate solution is to move to .Net 2.0 as we adopt a completely different approach in implementing the timeout logic.

One Reply to “General Network Error in .Net Framework 1.1”

Leave a Reply

Your email address will not be published. Required fields are marked *