Subject Re: [firebird-support] Concurrent Usage Limiting via Application
Author Stefan Heymann
Hi Tom,

> FB is currently our default database
Same here :-)

> and if anyone has any tips on how to handle/limit concurrent usage
> from an application then it would be appreciated.

The only thing you can currently do is retrieve a list of the names of
the users that are connected to the database (including yourself).

When you use Delphi and IbObjects you can use the IB_Connection.Users
property to get this list.

When I start my application, I retrieve this list and count the number
of currently attached users. As I don't use the Firebird security
mechanism to authenticate users (there is my own USERS table in my
database, which I find more convenient), all my users attach to the
database using the same Firebird user name. I only count the
connections from this user name so users that are connected as, say,
SYSDBA will not be counted (e.g. administrators using a DB tool).

> We currently use a per-machine registration code but would like to
> monitor and limit connections instead.

That's difficult and unprecise. Mainly because ...

> Also, does anyone know if it possible to track untimely client
> disconnections?

... of this one: it's not possible. When a connection gets lost, the
Firebird server still keeps them in its list. The only way to reset
the list seems to be a restart of the Firebird service.

However, in firebird.conf there is a setting DummyPacketInterval, the
description mentions KEEPALIVE messages:

> # Seconds to wait on a silent client connection before the server sends
> # dummy packets to request acknowledgment.
> #
> # DO NOT USE THIS OPTION. It may hang or crash Windows on the client side as
> # explained here:
> # or may not prevent eventual inactive client disconnection for other OS.
> #
> # Normally, Firebird uses SO_KEEPALIVE socket option to keep track of
> # active connections. If you do not like default 2-hour keepalive timeout
> # then adjust your server OS settings appropriately. On UNIX-like OS's,
> # modify contents of /proc/sys/net/ipv4/tcp_keepalive_*. On Windows,
> # follow instrutions of this article:
> #

Maybe the last article on Microsoft's homepage can help. I didn't try
that so far but "DO NOT USE THIS OPTION" doesn't sound very
encouraging ...

Being able to get a list of connected users with their IP address, OS
user name, client application name/identifier and timestamp of
connection would be my number one wish for any future release of
Firebird. For me, that would be more important and helpful than, say,
further speed improvements of the SQL query optimizer ...

Best Regards


Stefan Heymann