Vscode-sqltools: Cannot connect to Azure SQL anymore

Created on 4 Feb 2019  路  7Comments  路  Source: mtxr/vscode-sqltools

Describe the bug

Trying to connect to any Azure SQL server instance fails with the exception:

Error: Request connection/openConnection failed with message: Requests can only be made in the LoggedIn state, not the LoggedInSendingInitialSql state
    at handleResponse (C:\Users\ran\.vscode\extensions\mtxr.sqltools-0.16.7\node_modules\vscode-jsonrpc\lib\main.js:436:48)
    at processMessageQueue (C:\Users\ran\.vscode\extensions\mtxr.sqltools-0.16.7\node_modules\vscode-jsonrpc\lib\main.js:263:17)
    at Immediate.setImmediate [as _onImmediate] (C:\Users\ran\.vscode\extensions\mtxr.sqltools-0.16.7\node_modules\vscode-jsonrpc\lib\main.js:247:13)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)

To Reproduce
Steps to reproduce the behavior:

  1. Configure a new connection to an Azure SQL instance.
  2. Try to connect.

Expected behavior
A connection is established, Assuming all details (URL, username, password etc) are correct.

Desktop (please complete the following information):

  • OS: Windows 10 x64 1809
  • Version: 0.16.7

Example configured connection:

{
    "server": "MYSERVERHERE.database.windows.net",
    "name": "PROD DB",
    "askForPassword": true,
    "dialect": "MSSQL",
    "dialectOptions": {
        "encrypt": true
    },
    "database": "DB-NAME",
    "port": 1433,
    "username": "myAzureSQLAdminUser"
}
bug mssql rdbms dialect

Most helpful comment

Confirmed, Works well now. Thanks!

All 7 comments

Hi @ransagy.

I'll take a look. For version 0.16.7 I've upgrade some libraries, including the one for SQL Server.

Do you use any other server there? Even if it's for other dialects like MySQL.

Thanks for reporting this shortly.

Also, do you have this connection set to autoConnectTo?

@mtxr thank you for the quick response!

While this allowed me to move forward, It still didn't work. Despite having "encrypt": true in my dialect options as noted above, I still get the following error in the log:

(node:17028) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): ConnectionError: Server requires encryption, set 'encrypt' config option to true.

I'll reopen and take a second look into it

Just to keep you up to date, this warning is probably because of this:

https://github.com/mtxr/vscode-sqltools/blob/0a4565168b25b62058bd49139fd86ba37dd5fc27/packages/core/dialect/mssql.ts#L71-L98

Since the "encrypt" flag is a now issue because of miss configuration, I've decided to do a retry if fail and try without encryption.

As far as i know, Connections to Azure SQL have to be encrypted. Usually when specififying connection strings elsewhere, like in .NET, i have to supply the ;Trusted_Connection=False;Encrypt=True; parameters.
I think encrypt is enough though.

I'll test it again as soon as there's a release.

Confirmed, Works well now. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

glha picture glha  路  7Comments

abenhamdine picture abenhamdine  路  6Comments

bergamin picture bergamin  路  3Comments

sideshow-systems picture sideshow-systems  路  4Comments

benyaminl picture benyaminl  路  5Comments