The driver may report one or both of the errors depending on the timeout setting and the usability of the connection.
When the driver detects that the timeout has occurred, it will also try to determine if the connection is still valid and usable.
If the driver determines that the connection is still usable (socket is not closed) then it will report that the network operation has timed out. If the driver determines that the connection is no longer valid, then it will report that the network operation has timed out and also that the connection is dead.
The "connection dead" error can appear by itself if the driver attempts to communicate with the server and discovers that the socket has been closed.
The "connection dead" error can also appear by itself if the host and/or port is incorrect. This can be further confirmed by enabling packet logging with the driver. If the log does not contain any response packets from the server, this is a strong indication that the host and/or port are incorrect.
In the case of just the error "Network Operation timed out", the driver has detected that the timeout has been reached but still considers the connection to be valid and usable.
In the case when seeing both the "Network Operation timed out" and "Connection dead" together, the driver is timing out and also detects that the connection is no longer usable.
The driver determines whether a connection is valid by doing the following:
The driver sends an interrupt to the server to determine whether the connection is valid. The interrupt is used to cancel the current request.
If any of the following are true, then the connection is considered valid and usable:
- The server replies with a cancel acknowledgement
- The server replies with a valid response to the original request.
- If the server has not replied, a simple database operation is performed. The operation is to open and close a cursor.
Otherwise, the connection is no longer usable and the socket is closed.