Article ID: 2605597 - Last Review: April 27, 2012 - Revision: 5.0 FIX: Time-out error when a mirrored database connection is created by the .NET Framework data provider for SQLClient
On This PageSYMPTOMSWhen an application uses the Microsoft .NET Framework 3.5 or Microsoft .NET Framework 4 data provider for Microsoft SQL Server (SQLClient) to connect to a mirrored database, you may receive the following error message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error) at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket() at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean& marsCapable) at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.LoginWithFailover(Boolean useFailoverHost, ServerInfo primaryServerInfo, String failoverHost, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) CAUSEThis issue occurs because of an error in the connection-retry algorithm for mirrored databases. When the retry-algorithm is used, the data provider waits for the first read (SniReadSync) call to finish. The call is sent to the back-end computer that is running SQL Server, and the waiting time is calculated by multiplying the connection time-out value by 0.08. However, the data provider incorrectly sets a connection to a doomed state if a response is slow and if the first SniReadSync call is not completed before the waiting time expires. Note The slow response in this case may be triggered either by the server or by network latency. RESOLUTIONHotfix informationA supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing the problem described in this article. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix. Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft website: http://support.microsoft.com/contactus/?ws=support
(http://support.microsoft.com/contactus/?ws=support)
Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.PrerequisitesThere are two hotixes for this issue. One hotfix applies to the .NET Framework 3.5.1 and one hotfix applies to the .NET Framework 4.0. To apply the hotfix for the Microsoft .NET Framework 3.5.1, you must have the .NET Framework 3.5.1 installed on a computer that is running one of the following operating systems:
Restart requirementYou do not have to restart the computer after you apply this hotfix.Hotfix replacement informationThis hotfix does not replace a previously released hotfix.File informationThe global version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.File information for the .Net Framework 3.5.1For all supported x86-based versions of Windows 7Collapse this table
For all supported x64-based versions of Windows 7 and of Windows Server 2008 R2Collapse this table
For all supported IA-64–based versions of Windows Server 2008 R2Collapse this table
File information for the .Net Framework 4.0For all supported x86-based versions of Windows 7Collapse this table
For all supported x64-based versions of Windows 7 and of Windows Server 2008 R2Collapse this table
For all supported IA-64–based versions of Windows Server 2008 R2Collapse this table
WORKAROUNDTo work around this issue, use one of the following methods:
MORE INFORMATIONThe following screen shot displays a network capture
(http://www.microsoft.com/downloads/en/details.aspx?FamilyID=983b941d-06cb-4658-b7f6-3088333d062f&displaylang=en)
between the App Server and SQL Server at the time that the problem occurred in a test scenario: Collapse this image ![]() In this example, we can see that the App Server closes the connection (Frame 670 AF packet) about one second into the initial connection phase (TDS:Prelogin). When the SQL Server responds at five seconds, this response is too late, and client resets the connection. As explained in the "Cause" section, when Connection Timeout is set to 15 seconds (the default value), the actual Connection Timeout that is calculated by the Connection retry algorithm for mirroring is equal to 1.2 sec (.08*15). The following is a BID trace (http://msdn.microsoft.com/en-us/library/cc765421(SQL.100).aspx) that was captured from the test App Server: To obtain the ring buffer output from Management Studio, run the following query: REFERENCESFor more information about the SqlConnection.ConnectionTimeout property, visit the following MSDN website: General information about the SqlConnection.ConnectionTimeout property
(http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx)
For more information about the connection retry algorithm for TCP/IP connections, visit the following MSDN website:General information about the connection retry algorithm for TCP/IP connections
(http://msdn.microsoft.com/en-us/library/ms365783.aspx)
For more information about the System.Data.SqlClient namespace, visit the following MSDN website:General information about the System.Data.SqlClient namespace
(http://msdn.microsoft.com/en-us/library/system.data.sqlclient.aspx)
For more information about database mirroring, visit the following MSDN website:General information about database mirroring
(http://msdn.microsoft.com/en-us/library/ms189852.aspx)
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. APPLIES TO
| Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top

