Skip to content

Received "error: 25 - Connection string is not valid" after upgrading from 2.0.1 to 2.1.1  #904

@chgl

Description

@chgl

(Originally raised at microsoft/fhir-server#1623)

Describe the bug

After upgrading from version 2.0.1 to 2.1.1 a Microsoft.Data.SqlClient.SqlException (0x80131904) is thrown stating that the previously working connection string is invalid (provider: TCP Provider, error: 25 - Connection string is not valid)

The connection string looks roughly like this:

Server=tcp:db.example.com\INSTANCE1,1533;Initial Catalog=FHIR;Persist Security Info=False;User ID=fhir;Password=password123;MultipleActiveResultSets=False;Connection Timeout=30

Maybe it's related to the INSTANCE1 or custom port 1533?

Exception message: 

Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 25 - Connection string is not valid)

Stack trace:

2021-01-30T21:26:12.979963942+01:00 stderr F Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 25 - Connection string is not valid)
2021-01-30T21:26:12.980011342+01:00 stderr F at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
2021-01-30T21:26:12.980021741+01:00 stderr F at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
2021-01-30T21:26:12.980028556+01:00 stderr F at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType)
2021-01-30T21:26:12.980035159+01:00 stderr F at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
2021-01-30T21:26:12.980040736+01:00 stderr F at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
2021-01-30T21:26:12.980046285+01:00 stderr F at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
2021-01-30T21:26:12.980051461+01:00 stderr F at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool)
2021-01-30T21:26:12.980057528+01:00 stderr F at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
2021-01-30T21:26:12.980061709+01:00 stderr F at Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
2021-01-30T21:26:12.980066544+01:00 stderr F at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
2021-01-30T21:26:12.980084277+01:00 stderr F at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
2021-01-30T21:26:12.980088854+01:00 stderr F at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
2021-01-30T21:26:12.980093862+01:00 stderr F at Microsoft.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
2021-01-30T21:26:12.980098807+01:00 stderr F --- End of stack trace from previous location where exception was thrown ---
2021-01-30T21:26:12.980102605+01:00 stderr F at Microsoft.Health.SqlServer.Features.Schema.SchemaInitializer.DoesDatabaseExistAsync(SqlConnection sqlConnection, String databaseName, CancellationToken cancellationToken)
2021-01-30T21:26:12.980106458+01:00 stderr F at Microsoft.Health.SqlServer.Features.Schema.SchemaInitializer.CanInitializeAsync(CancellationToken cancellationToken)
2021-01-30T21:26:12.980111196+01:00 stderr F at Microsoft.Health.SqlServer.Features.Schema.SchemaInitializer.InitializeAsync(Boolean forceIncrementalSchemaUpgrade, CancellationToken cancellationToken)
2021-01-30T21:26:12.980117559+01:00 stderr F at Microsoft.Health.SqlServer.Features.Schema.SchemaInitializer.StartAsync(CancellationToken cancellationToken)
2021-01-30T21:26:12.980123754+01:00 stderr F at Microsoft.AspNetCore.Hosting.HostedServiceExecutor.ExecuteAsync(Func`2 callback, Boolean throwOnFirstFailure)
2021-01-30T21:26:12.980142748+01:00 stderr F at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
2021-01-30T21:26:12.980151637+01:00 stderr F at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
2021-01-30T21:26:12.980161216+01:00 stderr F at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
2021-01-30T21:26:12.980167288+01:00 stderr F at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
2021-01-30T21:26:12.980172955+01:00 stderr F at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
2021-01-30T21:26:12.980178578+01:00 stderr F at Microsoft.Health.Fhir.Web.Program.Main(String[] args) in /repo/src/Microsoft.Health.Fhir.Shared.Web/Program.cs:line 40
2021-01-30T21:26:12.98018441+01:00 stderr F ClientConnectionId:00000000-0000-0000-0000-000000000000

To reproduce

I was unable to provide an isolated way to reproduce it (see microsoft/fhir-server#1623 (comment) for my attempt), so it might be related to the configuration of the local SQL Server.

Expected behavior

The connection to the SQL server should succeed as it did with version 2.0.1.

Further technical details

Microsoft.Data.SqlClient version: v2.1.1
.NET target: .NET Core 3.1
SQL Server version: 14.00.3356.
Operating system: Windows Server 2019

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions