bestlong / node-red-contrib-mssql-plus

A Node-RED node to read and write to Microsoft MS SQL Databases
MIT License
31 stars 18 forks source link

error connecting to ms sql server 2019 linux / docker #54

Closed na-am closed 2 years ago

na-am commented 2 years ago

Hi i've no success to connect to a linux ms sql server in a docker container besides, i can connect from a windows client to the ms sql server and also from Azure Data Studio (MacOS)

what i noticed is, that the windows client shows me no instance name for the linux ms sql server, just a servername (mssqlserver) that page says, that the linux version has no instance name: https://stackoverflow.com/questions/41695344/how-can-i-create-named-instance-of-microsoft-sql-server-on-ubuntu could that be the problem?

error msg with instance name 'mssqlserver': Failed to connect to ip\mssqlserver error msg w/o an instance name: invalid syntax near '-'.

thanks

Steve-Mcl commented 2 years ago

Hi.

Can you show a screenshot of the working connection details from azure data studio and a screenshot of what you enter into the node connection setup?

na-am commented 2 years ago

Azure Data Studio query image

Node-red settings: image

Node-red and Data Studio are running on the same machine

Steve-Mcl commented 2 years ago

You didnt show me the connection detail for Data Studio - never mind.

the port number is possibly not 1433

Look in the console for "listening"...

2021-07-07 09:29:11.38 spid19s     Server is listening on [ 'any' <ipv6> 1433].                                                                                                                                                                                                                                                                                                                                                      
2021-07-07 09:29:11.38 spid19s     Server is listening on [ 'any' <ipv4> 1433].                                                                                                                                                                                                                                                                                                                                                      
2021-07-07 09:29:11.39 Server      Server is listening on [ ::1 <ipv6> 1434].                                                                                                                                                                                                                                                                                                                                                        
2021-07-07 09:29:11.40 Server      Server is listening on [ 127.0.0.1 <ipv4> 1434].   

If you cant find docker logs, then look in the sql log

image


Regarding instance name, you can use 'localhost\instance' to connect to named instance

na-am commented 2 years ago

this is the log from the docker container: image

na-am commented 2 years ago

there is no port given in the settings of Data Studio: image

this screenshot belongs to the windows client: MSSM

Steve-Mcl commented 2 years ago

Hi, can you try 3 things please...

image

  1. Disable Use Encryption, deploy, test.

  2. Remove database name, , deploy, test.

  3. Set host name to IP.ADD.RE.SS\MSSQLSERVER, deploy, test.

Please be sure to deploy and test after each individual change.

Let me know how you get on.

Ta.

na-am commented 2 years ago

no success, BUT..... surprise, surprise with native node it's working :-) and yes, encrypt must be false otherwise no connection is possible

x = sql.connect('Server=10.6.0.89,1433;Database=ms;User Id=nodered;Password=xxx;Encrypt=false') Promise { } console.dir(x) Promise { ConnectionPool { _events: [Object: null prototype] {}, _eventsCount: 0, _maxListeners: undefined, _connectStack: [], _closeStack: [], _connected: true, _connecting: false, _healthy: true, config: { options: [Object], pool: {}, port: 1433, server: '10.6.0.89', database: 'ms', domain: undefined, user: 'nodered', password: 'xxx', stream: false, parseJSON: false, arrayRowMode: false, validateConnection: true }, close: [Function: bound globalClose], pool: Pool { destroyed: false, emitter: [EventEmitter], creator: [Function: create], destroyer: [Function: bound _poolDestroy], validate: [Function: bound _poolValidate], log: [Function (anonymous)], acquireTimeoutMillis: 30000, createTimeoutMillis: 30000, destroyTimeoutMillis: 5000, idleTimeoutMillis: 30000, reapIntervalMillis: 1000, createRetryIntervalMillis: 200, propagateCreateError: true, min: 0, max: 10, used: [], free: [], pendingCreates: [], pendingAcquires: [], pendingDestroys: [], pendingValidations: [], interval: null, eventId: 1 },

} }

na-am commented 2 years ago

sorry for wasting your time Steve now it's working in Node-red encription=true was one reason AND a faulty syntax in my select statement :-(

Steve-Mcl commented 2 years ago

No bother. Glad it's sorted.