Επεξεργασία

Κοινή χρήση μέσω


Intermittent connection errors occur when using SQLCMD utility

This article helps you resolve intermittent connection "OS error 10054" issues that occur when you use the SQLCMD command line tool.

Errors

You receive the following warning and error messages:

WARNING: proc_procname returned HResult 0x2746, Level 16, State 1

TCP Provider: An existing connection was forcibly closed by the remote host.

SQLCMD.EXE : Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Client unable to establish connection

One possible cause of these errors is an unsupported driver.

Questions to consider

Review the following scenarios to determine whether any match your issue:

  • You collect a network trace and learn that TLS 1.0 and 1.1 are disabled and TLS 1.2 is enabled. On the server that's running SQL Server, TLS 1.0, 1.1, and 1.2 are enabled on the application server.

    Screenshot that shows that TLS 1.0, 1.1, and 1.2 are enabled on the application server.

  • You run a UDL test on the application server by using both the Microsoft OLE DB Provider for SQL Server and the SNAC 11 provider. The connection fails. You also receive a message that states that the "Microsoft OLE DB Provider for SQL Server" driver is deprecated and doesn't support TLS 1.2.

  • The application server uses SQL Server Native Client 11 to successfully test the ODBC data source. If SQL Server Native Client 10.0 isn't supported, you might receive the following error message:

    The connection failed with SQL State: '08001' SQL Server Error: 10054 [Microsoft][SQL Server Native Client 10.0]TCP Provider: An existing connection was forcibly closed by remote host. [Microsoft][SQL Server Native Client 10.0] Client unable to establish connection.

    This message might be displayed because the application server uses the older version of Diffie-Hellman algorithm (v1) and SQL Server uses the newer version (v2). This mismatch causes intermittent TLS failures.

Resolution

To resolve these issues, follow these steps:

  1. Specify SQL Server Native Client 11 in the connection string.

    Note

    Microsoft no longer supports SNAC 11. If you experience any issues while you use SNAC 11, you must upgrade to a supported version of the Microsoft driver before technical support can be provided.

  2. Upgrade the application driver to a supported driver.

  3. Use MSOLEDBSQL v18 or ODBC v17 if you aren't using encryption for the connection. If you are using encryption for the connection on the application server, use MSOLEDBSQL v19 or ODBC v18. By default, these drivers are included together with the encryption. For more information, see the following articles:

See also

An existing connection was forcibly closed by the remote host (OS error 10054)