IntelliTect / IntelliTect.AspNetCore.SignalR.SqlServer

A Microsoft SQL Server backplane for ASP.NET Core SignalR.
Apache License 2.0
39 stars 5 forks source link

Connection string validation #2

Closed JeremyCrookshank closed 2 years ago

JeremyCrookshank commented 3 years ago

It needs validation to ensure the connection string passed in is valid, it still output that it was installing the sql script even though it couldn't connect and didn't throw any exceptions.

Excellent repo btw

ascott18 commented 2 years ago

Thanks for the report. An error is now logged when initialization fails.

04:14:26 fail: IntelliTect.AspNetCore.SignalR.SqlServer.SqlServerHubLifetimeManager[0]
      Unable to install SignalR SQL objects
      System.ArgumentException: Keyword not supported: 'asdf'.
         at Microsoft.Data.Common.DbConnectionOptions.ParseInternal(Dictionary`2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms, Boolean firstKey)
         at Microsoft.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms)
         at Microsoft.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
         at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
         at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
         at Microsoft.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
         at Microsoft.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
         at Microsoft.Data.SqlClient.SqlConnection..ctor(String connectionString)
         at IntelliTect.AspNetCore.SignalR.SqlServer.Internal.SqlInstaller.Install() in C:\src\IntelliTect.AspNetCore.SignalR.SqlServer\src\IntelliTect.AspNetCore.SignalR.SqlServer\Internal\SqlServer\SqlInstaller.cs:line 33

Interestingly, the Redis provider also fails silently when it cannot connect. I had assumed the lack of handling around that meant that such failures would be logged by the SignalR infrastructure, but I was wrong to assume and not verify.