anli
anli

Reputation: 735

Connection timeout in Firebird Server 3

I'm connecting to a Firebird SQL Server version 3 with a C# application using Firebird .NET Client 9.1.1. Once the application is started 3 connections to the server are established using a connection pool. When the application quits in a normal way, all connections are closed. When the application is killed e.g. using the task manager or due to session timeout in the remote desktop only two connections are closed and one connection survives. These 'broken connections' idle since then. What do I need to set that these connections are killed, e. g. after 24 hours? I found an idle timeout setting for Firebird SQL Server 4.0 (https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref40/fblangref40-management-timeouts.html), but not for Firebird SQL Server 3.0.

I'm updating the question as I tried several things especially Marc Rotteveel mentioned:

#
# Seconds to wait on a silent client connection before the server sends
# dummy packets to request acknowledgment.
#
...
# Per-connection configurable.
#
# Type: integer
#
DummyPacketInterval = 1800

in the firebird.conf and restarted the server. However there are still connections being established four weeks ago (last server restart) but with the PIDs (e. g. 11280) not being present on the client anymore:

enter image description here

enter image description here

enter image description here

Upvotes: 0

Views: 1270

Answers (1)

Mark Rotteveel
Mark Rotteveel

Reputation: 108941

First, make sure you're querying an up-to-date snapshot of the monitoring tables. Once any monitoring table has been queried in a transaction, all other queries to any monitoring table will have a stable snapshot. You need to start a new transaction to get a new monitoring snapshot.

Second, you didn't specify which Firebird 3.0 version you're using: make sure you're using the latest version (3.0.10 at this time).

The termination of those connections should be detected eventually, and then they should be cleaned out. Normally, Firebird relies on the SO_KEEPALIVE socket option to detect broken connections. With the default TCP/IP settings on Windows, it should detect a broken connection within 2 hours.

If that doesn't happen (or not soon enough for your taste), you can check your Windows TCP/IP settings to check if the TCP keepalive setting has been modified or disabled (recent Windows versions no longer allow this to be disabled), in registry entry HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters (specifically KeepAliveTime and KeepAliveInterval, if these keys are absent, the defaults are applied, on older Windows versions keepalive is disabled when TcpMaxDataRetransmissions is set to 0).

Alternatively, you can set the DummyPacketInterval in firebird.conf to a non-zero value.

The DummyPacketInterval is a value in seconds where the server will send a "dummy" packet if a connection has been idle for at least that length of time. If a connection is gone, attempting to send that dummy packet will result in an error, which will make Firebird recognize the connection is no longer there.

Don't set the value too low, that will just result in unnecessary load and network traffic. I'd suggest to use an interval of 30 minutes (1800 seconds) or even higher.

Upvotes: 0

Related Questions