5

I am looking to connect to Firebird Server 3.0 using WireCompression. This being new feature since version 3.0 I'm having a hard time to get it to do so and the only documented instructions I can find is setting WireCompression to TRUE in firebird.conf and use the connect parameter "wirecompression=true".

This is what I've got this far:

firebird.conf:

# Firebird configuration file for Firebird 3.0 64-bit SuperServer
# Optimized by IBSurgeon (www.ib-aid.com) for HQbird distribution.
#

ServerMode = Super

#DatabaseAccess = Full
#RemoteAccess = true
#ExternalFileAccess = None
#UdfAccess = Restrict UDF
#TempDirectories =
#AuditTraceConfigFile =
#MaxUserTraceLogSize = 10

DefaultDbCachePages = 50000

#DatabaseGrowthIncrement = 128M
#FileSystemCacheThreshold = 64K
#FileSystemCacheSize = 0
#RemoteFileOpenAbility = 0

TempBlockSize = 2M
TempCacheLimit = 364M

AuthServer = Srp
AuthClient = Srp, Win_Sspi, Legacy_Auth
UserManager = Srp
#WireCryptPlugin = Arc4

#hqbird traceapi plugin should be in plugins folder!
TracePlugin = fbtrace2db

#CryptPlugin = Arc4
#KeyHolderPlugin =
#Providers = Remote,Engine12,Loopback
#DeadlockTimeout = 10
#MaxUnflushedWrites = 100
#MaxUnflushedWriteTime = 5
#BugcheckAbort = 0
#RelaxedAliasChecking = 0
#ConnectionTimeout = 180
#(for client) / Required (for server)

WireCompression = true
WireCrypt = enabled
#DummyPacketInterval = 0
#RemoteServiceName = gds_db

RemoteServicePort = 3050

#RemoteAuxPort = 0
#TcpRemoteBufferSize = 8192
#TcpNoNagle = 1
#RemoteBindAddress =

LockMemSize = 9M

#LockAcquireSpins = 0

LockHashSlots = 30011

#EventMemSize = 64K
#CpuAffinityMask = 0
#GCPolicy = combined
#SecurityDatabase = $(dir_secDb)/security3.fdb

GuardianOption = 1

#ProcessPriorityLevel = 0
#IpcName = FIREBIRD
#RemotePipeName = interbas

Code to connect:

  //Info: FDB = TFDConnection
  with FDB.Params do
  begin
      Clear;
      Add('DriverID=FB');
      Add('Database=' + vDatabase);
      Add('User_Name=' + AUsername);
      Add('PassWord=' + APassword);
      Add('WireCompression=true');
  end;

  FDB.FetchOptions.Unidirectional:= true;
  FDB.FetchOptions.RowsetSize:= 1000;
  FDB.ResourceOptions.SilentMode:= true;

  FDB.Connected := true;

  vConnectionInfo:= TStringList.Create;
  FDB.GetInfoReport(vConnectionInfo);

  ShowMessage(vConnectionInfo.Text);

  Clipboard.AsText:= vConnectionInfo.Text;

  FreeAndNil(vConnectionInfo);

  Result := FDB.Connected;

The connection is established, but vConnectionInfo says:

================================
Connection definition parameters
================================
DriverID=FB
Database=server:D:\Databases\FB3.0\test\test.FDB
User_Name=sysdba
PassWord=*****
WireCompression=true
================================
FireDAC info
================================
Tool = RAD Studio 10.1 Berlin
FireDAC = 15.0.1 (Build 86746)
Platform = Windows 32 bit
Defines = FireDAC_NOLOCALE_META;FireDAC_MONITOR
================================
Client info
================================
Loading driver FB ...
Brand = Firebird
Client version = 300009900
Client DLL name = D:\D10\Projects\TestFB30 Client\Win32\Debug\fbclient.dll
================================
Session info
================================
Current catalog = 
Current schema = 
Server version = WI-V3.0.0.32483 Firebird 3.0
WI-V3.0.0.32483 Firebird 3.0/tcp (server)/P13:C
WI-V3.0.0.32483 Firebird 3.0/tcp (laptop)/P13:C

Those last two lines say I have protocol v13 (P13) and the data is enCrypted (:C) but it should be P13:CZ indicating a zlib compression.

i have the zlib1.dll in the debug folder on the client side, and the zlib1.dll is present on the server in the Firebird server folder.

I can connect to the database, I get no error messages.

I am running out of ideas to get the compression to be applied, but I have faith in you guys to help me out!

  • Interesting q, +1, Are you relying on the Session info entries to tell you that compression is not being applied, or have you confirmed it using a packet sniffer? – MartynA Nov 30 '16 at 09:21
  • I am relying on session info currently. I tried interpreting wireshark packets but that's not really interpretable for me... i dont see readable data returned from a select query but since it is encrypted i suppose that is expected. – Christiaan ten Klooster Nov 30 '16 at 09:26
  • Even though troughput is significantly increased comparing legacy gds32.dll with IBX (5mbps) and fbclient.dll with FireDAC (50mbps) i would like to use compression for high latency (internet) connections. I can retrieve 120.000 records in 6 seconds now which is quite impressive, but with compression i guess that will be much much more. – Christiaan ten Klooster Nov 30 '16 at 09:31
  • Hopefully, this q will catch the eye of a Firebird expert, which I am not. How about an empirical method of seeing whether compression is likely being applied? F.i. use a query that should return a highly compressible result, such as a million repeats of the same character, and see whether the resulting network traffic looks like it has been compressed. – MartynA Nov 30 '16 at 09:35
  • Well, if i remove the WireCompression=true the traffic (and duration of data retrieval, and the throughput) and the session information is the same so i see no difference whatsoever. I guess that's empirical enough? the data consists of a client table with random names, email addresses etc so it should be very well compressable in my opinion – Christiaan ten Klooster Nov 30 '16 at 09:46
  • 1
    Have you tried adding a `firebird.conf` with `WireCompression = True` in the same location as your fbclient.dll? – Mark Rotteveel Nov 30 '16 at 09:48
  • Hi Mark, didn't know that was an option :) It does make a difference because now i get "First chance exception at $752BA6F2. Exception class EIBNativeException with message '[FireDAC][Phys][FB]Error reading data from the connection.'. Process firebird3test.exe (13824)" – Christiaan ten Klooster Nov 30 '16 at 10:02
  • 2
    Okay solution found: i copied zlib1.dll from the server - which is x64 after downloading zlib x86 and placing it in the same directory it has now Session info ================================ Current catalog = Current schema = Server version = WI-V3.0.0.32483 Firebird 3.0 WI-V3.0.0.32483 Firebird 3.0/tcp (h2402019)/P13:CZ WI-V3.0.0.32483 Firebird 3.0/tcp (laptop-chris)/P13:CZ – Christiaan ten Klooster Nov 30 '16 at 10:06

1 Answers1

5

In order to enable zlib compression using FireDAC all you need to do is:

  1. Enable wirecompression server side using firebird.conf by setting wirecompression=true
  2. Have the proper/same version of fbclient.dll client side
  3. Place the correct zlib1.dll (x86 in my case) in the folder that contains the client exe
  4. Create a firebird.conf and add the line wirecompression=true and save it to the same folder your exe is.
  5. Add wirecompression=true to the connection params

Wirecompression is now enabled.

  • Point 4 and 5 seem quite redundant. Do you really need both to have compression enabled? – Bozzy Mar 27 '18 at 08:38
  • 2
    Adding `wirecompression=true` to the `connection params` do nothing, only adding it to `firebird.conf` take effect – Livius Sep 12 '18 at 08:52
  • Only points 3 and 5 are really required. WireCompression is a client-only setting, not server-related. But the 5th item as stated is misleading since this is NOT a FDConnection parameter and should be passed at a lower level. I wrote a comprehensive answer [here](https://stackoverflow.com/a/57602217/33244). – F.D.Castel Aug 22 '19 at 04:59