Forum Discussion
Omar_Osman
2 years agoAdvocate I
Unsuccessful connect to SQL Endpoint using Node.js and tedious or mssql npm package
Software versions
- tedious: "^17.0.0"
- Node.js:18.17.1
var Connection = require("tedious").Connection;
var config = {
server:
//"****.datawarehouse.pbidedicated.windows.net",
"*****.datawarehouse.fabric.microsoft.com",
database: "Gold",
options: {
encrypt: true,
trustServerCertificate: false,
},
authentication: {
//type: "azure-active-directory-password",
type: "azure-active-directory-service-principal-secret",
options: {
//userName: "@.onmicrosoft.com",
//password: "****",
clientId: "****",
tenantId: "****",
clientSecret: "****",
},
},
};
var connection = new Connection(config);
connection.connect((err) => {
if (err) {
console.log("Connection Failed");
throw err;
}
console.log("Custom connection Succeeded");
connection.close();
});
Problem description
Got an error message when connecting to Microsoft Fabric SQL Endpoint
Got an error message when connecting to Microsoft Fabric SQL Endpoint
ConnectionError: Connection lost - socket hang up
{at Connection.socketError
... node_modules\tedious\lib\connection.js:1344:26)
code: 'ESOCKET'
}
Note:that the connection works when using the powershell with the same parameters.
Install-Module -Name SqlServer
$connectionString = "Server=$server;Database=$database;User Id=$username;Password=$password;Authentication=Active Directory Password;Encrypt=True;TrustServerCertificate=False;"
# Create a SQL connection
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlConnection.ConnectionString = $connectionString
Best Regards,
1 Reply
- lbendlinSuper User
that "socket hang up" seems to be a rather popular error message lately.
If you have a Pro license you can open a Pro ticket at https://admin.powerplatform.microsoft.com/newsupportticket/powerbi
Otherwise you can raise an issue at https://community.fabric.microsoft.com/t5/Issues/idb-p/Issues .