New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConnectTimeout to be made configurable #50
Comments
Set the connectTimeout at runtime by passing and options object to the Database constructor function: var db = require('odbc')({ connectTimeout : 60 }); or var odbc = require('odbc'); var db = new odbc.Database({ connectTimeout : 42 });
Hey Praveen, I did one better, I hope. I implemented the ability to change the I released v0.5.24 on my fork. You can set the connectTimeout like so: var db = require('odbc')({ connectTimeout : 60 }); or var odbc = require('odbc');
var db = new odbc.Database({ connectTimeout : 42 }); If the connectTimeout is 0 then a connection timeout won't be set. |
Install with Let me know if it works for you and we can close this issue. Thanks, Dan |
Assuming fixed. |
Curious, I'm running into an issue where this property seems to be ignored if the server is not accepting connections at all. I usually run SQL Server in a VM on my OSX machine, and use a If the VM is not running at all, then calls to var odbc = require('odbc');
var db = odbc({connectTimeout: 1});
console.log('Connecting with connectTimeout: 2');
console.time('connect');
db.open(process.env.CONNECTION_STRING, function(err) {
console.log('connect callback running');
if (err) console.error(err);
else console.log('connected!');
if (db.connected) db.close();
console.timeEnd('connect');
}); Output:
|
That is interesting. Is there anyway to test this with We use |
Ahh. Looks like there is a separate attribute for connection timeout: We should implement both the |
I should be able to get this fixed in a few minutes. |
This should fix #50. Previously we were using SQL_ATTR_LOGIN_TIMEOUT as the connect attribute for connectionTimeout. I think this is wrong. I have replaced the attribute with SQL_ATTR_CONNECTION_TIMEOUT and introduce another attribute called loginTimeout to set SQL_ATTR_LOGIN_TIMEOUT.
@rossipedia, could you test with odbc installed from If that works, I'll push out v0.6.5. |
That's much, much better, thanks for the prompt fix! EDIT Although, I might be having an issue now that the server's up. Testing... |
Yeah it's still bugged. Now I can't actually connect to the server even though it's running. |
Are you getting any errors or anything? I can't replicate. |
Let me put together a minimum-code replication |
Okay so I'm having trouble replicating this in isolation, and it's a travel day for me. I'll try to pin down what's going on in my existing codebase either tonight or tomorrow. |
OK. I'll hold off on merging this until we get this figured out. Safe travels. |
FYI: I am randomly encountering an assertion error in the FreeTDS driver when specifying a value for connectTimeout which in turn sets
Sometimes it does assert and some times it does not. May be a race condition some[where|how]. I'm not quite sure how though. We are using a mutex around the I do not have this issue with the SQL Server Native Client 11.0 driver and connectTimeout > 0. |
Hi Daniel
I see that the connectTimeOut interval is been set to 5 seconds, with a TODO for making it configurable.
We were trying to connect to DB2 server behind tight firewalls and started hitting a connect time out failure. Could you comment out setting the timeout until it is made configurable?
Thanks
Praveen
The text was updated successfully, but these errors were encountered: