2
votes

I have a simple node.js app that can't connect to a SQL Db.

Web server is Azure Web App, running node.js and using Tedious for SQL. DB is Azure SQL Database.

This is the detailed error:

{ message: 'Failed to connect to xxx.database.windows.net:1433 - undefined', code: 'ESOCKET' }

Thu Jan 14 2016 08:05:05 GMT+0000 (Coordinated Universal Time): Unaught exception: ConnectionError: Connection lost - connect EADDRNOTAVAIL at Connection. (D:\home\site\api\node_modules\tedious\lib\connection.js:797:26) at Socket. (D:\home\site\api\node_modules\tedious\lib\connection.js:33:15) at Socket.emit (events.js:88:20) at Array.1 (net.js:301:14) at EventEmitter._tickCallback (node.js:190:38)

It works on my machine, and the funny thing is that is also works on another Azure Web App! I tried restarting this web app and what not... What's this error means?

1
I had a similar problem before and it turned out I just had my connection string misformatted. I had even looked at it, but missed a minor error. Could you triple check your connection string? It helped me to log it to console. I eventually caught it when I manually passed it to connection string parser. - Chris Anderson-MSFT

1 Answers

2
votes

I tried to reproduce the issue, but failed. So I searched some keyworks like EADDRNOTAVAIL for NodeJS & Tedious, then I found the page https://github.com/nodejs/node-v0.x-archive/issues/6833.

It inspired me that the issue might be caused on some specified version node. You can find the node version of the bad WebApp at the url https://<the_bad_webapp_name>.scm.azurewebsites.net/Env, and compare with the fine one.

You can see alll node version supported by Azure at the url https://<node webapp name>.scm.azurewebsites.net/api/diagnostics/runtime of Node WebApp.

If their node version are different, you can try to specify the node version of Tedious works fine for the bad webapp, please refer to the doc https://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/ to know how to do it.

Hope it helps.