Page 1 of 1

Connection Timeout

Posted: Tue 13 May 2014 06:28
by BFS
Dear devart team,

is there any possibility to set a duration for the ibcconnection timeout.

The following log entry shows that the connection timeout on Task 17523 seems to be about 180 seconds.
20:21:29 Task 17592 [ 200783|TASKNAME ]: [778ms] abgeschlossen unauffällig
20:23:31 Task 17523 [ 200714| TASKNAME ]:
Unable to complete network request to host "DB-DEV".
Failed to establish a connection. FEHLER



We do several jobs in different threads, each thread has its own connection, transaction and query. Usually the database procedure runs about 1000 ms and so a timeout of 3 minutes is to much. :lol:

On the following code you see i tried to use the parameter 'connect_timeout=X', but it doesn't seems to be implemented.

Code: Select all

  try
    fCon := TIBCConnection.Create(nil);
    QryDo := TIBCQuery.Create(nil);
    fTran := TIBCTransaction.Create(nil);
//  try
    // Verbindungsparameter festlegen
    fCon.Database := DATABASE;
    fcon.Username := DBUSER;
    fCon.Password := DBPASS;
    QryDo.Connection := fCon;
    QryDo.Transaction := fTran;
    QryDo.Transaction.DefaultConnection := QryDo.Connection;
    QryDo.Transaction.IsolationLevel := iblcustom;

    QryDo.SQL.Text:=  ' select result from DO_SOMETHING ';
  
//    fcon.Params.Add('connect_timeout=5');
//    Sleep(10000);
    fcon.Connect;

    QryDo.Transaction.StartTransaction;
    QryDo.Open;
    result := QryDo.FieldByName('Result').AsBoolean;
    QryDo.Transaction.Commit;
    QryDo.Close;
    fcon.Disconnect;
  finally
    if QryDo.Transaction.Active then
      QryDo.Transaction.Rollback;
    if Assigned(fTran) then
      FreeAndNil(ftran);
    if Assigned(QryDo) then
      FreeAndNil(QryDo);
    if Assigned(fCon) then
      FreeAndNil(fCon);
  end;
We would be glad to hear from you.

Best Regards,
Jan
BFS Health finance

Re: Connection Timeout

Posted: Tue 13 May 2014 14:36
by PavloP
The connection_timeout server parameter affects the period of time in which broken connections will be closed. More details about the connection_timeout parameter can be found in the Firebird documentation.
Correct disconnection occurs after calling the Disconnect method of the TIBCConnection component. Therefore connection timeout doesn't affect your sample behavior.
Please investigate what exact operation takes the most part of task run time - connection establishing, SQL query execution, disconnect, etc.

Re: Connection Timeout

Posted: Wed 14 May 2014 06:28
by BFS
Hi,

thanks for your reply.

Now i understand, that the connection_timeout parameter wouldn't help me with our problem, but it doesn't matter anyway, because I'm not able to set this parameter. I think that interbase doesn't support it.

The operation, which takes the most part of task run time is the "fcon.connect".
In a few runs (2-5 of 50000) there is a problem with the network communication while connecting to the server (remote or local doesn't matter), so the connection could not be established.

An try-except-block direct at the fcon.connect shows the also posted exception:
Unable to complete network request to host "DB-DEV".
Failed to establish a connection.
I don't now if there is a problem at the interbase server, or a lower layer network problem. But i hope there is a way to stop the connection establishment at the client after an configurable time.

Best Regards,
Jan
BFS Health finance

Re: Connection Timeout

Posted: Wed 14 May 2014 10:50
by PavloP
Setting the connect_timeout variable via TIBCConnection.Params works correctly. However, take into account the fact that this parameter affects not on the connection establishing timeout, but on the period of time in which broken connections will be closed.
IBDAC has no capability to set timeout for connection establishing, since this term is defined by the client library - and we cannot affect this.