Using the TSQLConnection component in Delphi XE2 to connect to a DataSnap server.
My problem is that I would like to abort the connection attempt if we cannot connect after 3 seconds, however, setting the ConnectTimeout property for the driver has no effect (it still waits about 20 seconds before the failure).
I run this inside the thread, and so I can post a message to the thread (as, for example, depends on whether the thread's message queue is served), how this blocking call was created). Even if my stream message handler is running, I donβt know how I would then break the call lock to set the TSQLConnection.Connected property (which is set in the Stream's Execute method).
I would prefer not to call TerminateThread, as this seems unnecessary and will leave (if I understood correctly) the memory allocated for the thread stack. Any ideas on how to interrupt this connection process or access the basic Indy components and explicitly set the connection timeout will be appreciated.
Thank!
fConnection := TSQLConnection.Create(nil);
with fConnection do
begin
DriverName := 'DataSnap';
Params.Values['CommunicationProtocol'] := 'tcp/ip';
Params.Values['DatasnapContext'] := 'datasnap/';
Params.Values['HostName'] := '127.0.0.1';
Params.Values['Port'] := '211';
Params.Values['ConnectTimeout'] := '3000';
KeepConnection := true;
LoginPrompt := true;
end;
// Where it blocks for up to 20 seconds (if host unavailable)
fConnection.Connected := True;
source
share