Skip to content

Instantly share code, notes, and snippets.

@BradleyBoutcher
Last active January 13, 2020 21:27
Show Gist options
  • Save BradleyBoutcher/6cd2d5d25ac8fce9af733f07e0ba96b0 to your computer and use it in GitHub Desktop.
Save BradleyBoutcher/6cd2d5d25ac8fce9af733f07e0ba96b0 to your computer and use it in GitHub Desktop.
MsSQL Connector Problems

MsSQL Connector Problems

Bad/incompatible MsSQL client settings

Symptoms

  • You see an error in your Secretless logs that looks something like:
    [00] 2020/01/13 19:31:44 [WARN]  Starting TCP listener on 0.0.0.0:2223...
    [00] 2020/01/13 19:31:44 [INFO]  mssql: Starting service
    [00] 2020/01/13 19:31:44 [INFO]  Waiting for new configuration...
    [00] 2020/01/13 19:44:11 Instantiating provider 'literal'
    [00] 2020/01/13 19:44:11 [INFO]  mssql: New connection on x.x.x.x:2223.
    [00] 2020/01/13 19:44:11 [ERROR] mssql: Failed on handle connection: failed on connect: Unable to open tcp connection with host 'mssql:0': dial tcp x.x.x.x:0: connect: connection refused
    
  • Sample client log output messages
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
    

Known Causes

Generally you see an error like this if you attempt to open the client to Secretless connection without disabling SSL.

Resolution

MsSQL connections to Secretless from the client must have ssl-mode set to disabled (e.g. do not use -N when using SQLCMD). Ensure that ssl-mode is set to connect in this manner.

Incompatible MsSQL server settings

Symptoms

  • You see an error in your Secretless logs that looks something like:
    [00] 2020/01/13 21:19:34 Secretless v1.4.2-dev starting up...
    ...
    [00] 2020/01/13 21:19:34 [WARN]  Starting TCP listener on 0.0.0.0:2223...
    [00] 2020/01/13 21:19:34 [INFO]  mssql: Starting service
    [00] 2020/01/13 21:19:34 [INFO]  Waiting for new configuration...
    [00] 2020/01/13 21:19:34 Attaching filesystem notifier onto /secretless.yml
    [00] 2020/01/13 21:19:34 Registering reload signal listeners...
    [00] 2020/01/13 21:19:50 Instantiating provider 'literal'
    [00] 2020/01/13 21:19:50 [INFO]  mssql: New connection on 192.168.16.3:2223.
    [00] 2020/01/13 21:19:50 [ERROR] mssql: Failed on handle connection: failed on connect: lookup <host> on x.x.x.x:53: no such host
    
  • Sample client log output messages
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Timeout error [258]. .
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Unable to complete login process due to delay in prelogin response.
    

Known Causes

These errors can occur when the MsSQL server is unreachable at the configured host/port or when its configuration is incompatible with the configuration you provided the client and/or Secretless.

Resolution

  • Ensure that the backend details for MsSQL in Secretless configuration match the connection details for your database.
  • Attempt to connect directly to your database using the credentials to ensure that the backend is working properly.

Bad MsSQL authentication details

Symptoms

  • You see an error in your Secretless logs that looks something like:
    [00] 2020/01/13 20:58:13 Secretless v1.4.2-dev starting up...
    ...
    [00] 2020/01/13 20:58:13 [WARN]  Starting TCP listener on 0.0.0.0:2223...
    [00] 2020/01/13 20:58:13 [INFO]  mssql: Starting service
    [00] 2020/01/13 20:58:13 [INFO]  Waiting for new configuration...
    [00] 2020/01/13 20:58:13 Attaching filesystem notifier onto /secretless.yml
    [00] 2020/01/13 20:58:13 Registering reload signal listeners...
    [00] 2020/01/13 20:59:05 Instantiating provider 'literal'
    [00] 2020/01/13 20:59:05 [INFO]  mssql: New connection on 172.27.0.3:2223.
    [00] 2020/01/13 20:59:05 [ERROR] mssql: Failed on handle connection: failed on connect: Login error: mssql: Login failed for user 'bad'.           
    
  • Sample client log output messages
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'sa'..
    

Known Causes

This error can occur when you have provided Secretless with invalid credentials for the service in the configuration.

Resolution

  • Ensure that authentication details for your connection to Secretless in the configuration are valid.
  • Attempt to connect directly to the database using those connection details to ensure that they are correct.

Known Causes

You are using a version of MsSQL that is not currently supported by Secretless.

Resolution

Ensure that your backend is a supported version of MsSQL by Secretless

Missing or Invalid Port for MsSQL

Symptoms

  • You see an error in your Secretless logs that looks something like:
    [00] 2020/01/13 20:19:13 Secretless v1.4.2-dev starting up...
    ...
    [00] 2020/01/13 20:19:13 Registering reload signal listeners...
    [00] 2020/01/13 20:19:13 [WARN]  Starting TCP listener on 0.0.0.0:2223...
    [00] 2020/01/13 20:19:13 [INFO]  mssql: Starting service
    [00] 2020/01/13 20:19:13 [INFO]  Waiting for new configuration...
    [00] 2020/01/13 20:21:13 Instantiating provider 'literal'
    [00] 2020/01/13 20:21:13 [INFO]  mssql: New connection on x.x.x.x:2223.
    [00] 2020/01/13 20:21:13 [ERROR] mssql: Failed on handle connection: failed on connect: Unable to open tcp connection with host 'mssql:<invalid port>': dial tcp x.x.x.x:<invalid port>: connect: connection refused
    
  • Your client hangs as Secretless tries to connect and eventually times out with an error, because Secretless was provided with an invalid port in its configuration:
    sqlcmd -S "localhost,2223" -U "x" -P "x" -Q "SELECT 1+1"
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Timeout error [258]. .
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Unable to complete login process due to delay in prelogin response.
    

Known Causes

You have not provided a valid port to Secretless.

Resolution

Ensure that port is provided in the Secretless configuration is valid for the MsSQL server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment