RequestError: Requests can only be made in the LoggedIn state, not the Connecting state
See original GitHub issueI see this error was talked about here: https://github.com/tediousjs/tedious/issues/458 and I tried the suggested solution, but it didn’t work for me.
Here is my code:
`
exports.exec_sql_cmd = async function(cmd)
{
var config = {
server: 'xx.xx.xx.xx',
authentication: {
type: 'ntlm',
options: {
userName: 'master',
password: 'masterp',
domain: 'the.domain.com'
}
},
options: {
encrypt: false,
database: 'tblTest'
}
};
var connection = new Connection(config);
connection.on('connect', function(err) {
console.log("Connected");
executeStatement();
});
connection.connect();
function executeStatement() {
var request = new Request(cmd, function(err) {
if (err) {
console.log(err);}
});
request.on('row', function(columns) {
columns.forEach(function(column) {
if (column.value === null) {
console.log('NULL');
} else {
console.log("Row Inserted");
}
});
});
request.on("requestCompleted", function (rowCount, more) {
connection.close();
});
connection.execSql(request);
}
}
`
I do get connected (this line runs: console.log(“Connected”); ), but then this error is thrown:
RequestError: Requests can only be made in the LoggedIn state, not the Connecting state
The context of all this is: I’m trying to perform an INSERT from AWS Lambda back down to an On-Prem MS SQL database.
Thanks in advance.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
Requests can only be made in the LoggedIn state, not ...
In my example below, I'm trying to serially execute an array of functions. But the Requests can only be made in the LoggedIn...
Read more >Requests can only be made in the LoggedIn state, not ...
Try checking and reporting connection errors, i.e.: connection.on("connect", function (err) { if(err) { console.log('Error: ', err) } else ...
Read more >问答- 腾讯云开发者社区-腾讯云
sqlsql-servernode.jsrequestconnect ... Connected { RequestError: Requests can only be made in the LoggedIn state, not the Connecting state at RequestError ...
Read more >Requests Can Only Be Made In The Loggedin State Not
I am starting a nodejs project and I need to connect my app to a sql server database.Using tedious I'm making the connection...
Read more >[Solved]-Requests can only be made in the LoggedIn state ...
[Solved]-Requests can only be made in the LoggedIn state, not the SentClientRequest state-node.js ... The solution is using from one query request and....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m not 100% sure if this is the same issue you have, but there has been an issue with NTLM authentication when using Node 17 (as Tedious does not officially support Node 17 currently). If you throw the error inside of this block:
and you see an error message similar to this one: https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported, Node 17 may be the issue since Node upgraded to OpenSSL v3 and there are some compatibility issues. If it is possible to downgrade to Node 16, try that.
If that does not fix your issue, can you enable debugging to see a more detailed log?
Then add this event listener to output the debug messages:
Sorry for the late response. But I did switch back to Node 16 and it worked.
Thank you for your help!