Question on TMSConnection.ConnectionTimeout

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
brace
Posts: 227
Joined: Wed 14 Feb 2007 08:26

Question on TMSConnection.ConnectionTimeout

Post by brace » Tue 09 May 2017 10:24

I would like to know as soon as possible when a Connection fails.

I tried to set TMSConnection.ConnectionTimeout to a low number of seconds for this.

In case of a sql authentication there are 4 parameters: user, password, server and database.

I noticed that if user, password or database are wrong the TMSConnection raises an exception immediately, independently from the value of ConnectionTimeout, while if the server is wrong the exception comes about after the number of seconds specified in ConnectionTimeout.

Somehow the server property "takes longer", why?

Thanks.

I have latest sdac.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Question on TMSConnection.ConnectionTimeout

Post by azyk » Thu 11 May 2017 14:12

During establishing a connection SDAC refers to SQL Server and waits for its response. In case when Server does not exist or there is no access to it - SDAC will not get a response from SQL Server and after the ConnectionTimeout seconds it will raise an exception.

If there is access to Server, and Username/Password/Database are incorrect, then SDAC will not wait for the ConnectionTimeout seconds, and will give the app SQL Server response (error message) as soon as it gets it.

brace
Posts: 227
Joined: Wed 14 Feb 2007 08:26

Re: Question on TMSConnection.ConnectionTimeout

Post by brace » Thu 11 May 2017 15:08

So which is the need for the ConnectionTimeout property? ANd why the defalut value is as big as 15 seconds?
Isn't it always better to have a reply asap?

Or this is to handle timing in some particuar scenarios?

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Question on TMSConnection.ConnectionTimeout

Post by azyk » Fri 12 May 2017 12:18

ConnectionTimeout determines the time for which SDAC will be waiting for a response from SQL Server when attempting to establich a connection. If SDAC gets a response from SQL Server earlier than for a number of seconds in ConnectionTimeout, then SDAC will immediately return a response from SQL Server to the application. If a response from the server does not come, then we will wait for a response for ConnectionTimeout seconds, and only then return an error that the connection failed to be established.

You can empirically find out optimal ConnectionTimeout value for a custom application in your environment.

Post Reply