Lazarus Firebird remote connection problems lazarus / 16-Databases ---------------------------------------------------------------------- Ferke · 2018-02-22 11:44 Hi, I'm using Lazarus 1.6 (32 and 64 bits) with Firebird 3.0 32 bit. Lazarus is set to compile to 32 bit. My problem is that I cannot make my program to connect to FB database remotely. If I run my program on the server everything works fine. I have checked everything, I can connect to the database using the isql tool. Please correct me I set something wrong. Parameters of TIBConnection: DatabaseName: C:\DB\DB.FDB <-- Here goes the path to DB file on the host (DB server) computer. Host: 192.168.1.1 <-- IP address or name of the server. I tried to leave it blank and extended the DatabaseName like 192.168.1.1:C:\DB\DB.FDB I copied the DLLs into the folder of the program. I don't know if that is necessary. Additional question: Do I need to share the folder of the DB file on the network? I did earlier, and the DatabaseName was the path to the file from the client computer, but when I used isql tool I realized that I needed the path on the host. Server runs in Classic mode. Thank you very much in advance. BR, Ferenc ---------------------------------------------------------------------- rvk · 2018-02-22 12:26 First of all, can you connect to the servers database with the isql tool ON THE CLIENT? If you can, then everything should work. Otherwise: *) 192.168.1.1 is usually a router. Are you sure that is a real server on that IP? (check with ipconfig /all on that machine). *) Did you add a exception rule for firebird.exe in the firewall (or disabled the firewall and possible anti-virus completely). *) Did you install the firebirdclient on the client. *) Open a cmd prompt on the server and type netstat -an | findstr 3050     Is a process listening on TCP 0.0.0.0:3050 ? Otherwise you need to make sure firebird is listening on its network ip. DLLs in the program directory shouldn't be necessary (they also weren't on the server when you tested, I assume) ---------------------------------------------------------------------- Ferke · 2018-02-22 12:33 First of all, thanks for your answer, very appreciated. First of all, can you connect to the servers database with the isql tool ON THE CLIENT? Yes. ) 192.168.1.1 is usually a router. Are you sure that is a real server on that IP? (check with ipconfig /all on that machine). This IP is fake in my example. In fact that is home server with fix IP. *) Did you add a exception rule for firebird.exe in the firewall (or disabled the firewall and possible anti-virus completely). Ports are open and I could connect withthe ISQL tool. *) Did you install the firebirdclient on the client. No. That is missing. I thought the DLL-s should be enough. *) Open a cmd prompt on the server and type netstat -an | findstr 3050     Is a process listening on TCP 0.0.0.0:3050 ? Otherwise you need to make sure firebird is listening on its network ip. Yes, this was the first thing I checked earlier. DLLs in the program directory shouldn't be necessary (they also weren't on the server when you tested, I assume). Okay. Thanks, I will make a test with the client nstallation. ---------------------------------------------------------------------- Ferke · 2018-02-22 14:52 The client install did not help... ---------------------------------------------------------------------- valdir.marcos · 2018-02-22 17:00 Some properties for you to check (TIBConnection, TSQLQuery and TSQLTransaction components): http://wiki.freepascal.org/SqlDBHowto#How_to_connect_to_a_database_ser ver.3F http://wiki.freepascal.org/Firebird http://forum.lazarus.freepascal.org/index.php/topic,37238.msg249685.ht ml#msg249685 http://forum.lazarus.freepascal.org/index.php/topic,34145.msg222957.ht ml#msg222957 http://forum.lazarus.freepascal.org/index.php/topic,3485.msg122877.htm l#msg122877 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function CreateDataBaseConnection(): integer;  begin    FConnection := TIBConnection.Create(nil);    FTransaction := TSQLTransaction.Create(nil);    Result := 0;    try      try        FConnection.HostName := 'myHost';        FConnection.DatabaseName := 'myDataBaseName.gdb';        FConnection.UserName := 'sysdba';        FConnection.Password := 'masterkey';        FConnection.CharSet := 'ISO8859_1';        FConnection.Dialect := 3;        FConnection.Params.Add('PAGE_SIZE=8194');        FConnection.LoginPrompt := False;        FTransaction.Active := False;        FConnection.Connected := True;         FTransaction.DataBase := FConnection;        FTransaction.Params.Add('isc_tpb_read_committed');  // Transaction isolation levels        FTransaction.Params.Add('isc_tpb_read');          // Access mode        FTransaction.Params.Add('isc_tpb_nowait');        // Lock resolution        FTransaction.Params.Add('isc_tpb_rec_version');     // Record versions         FTransaction.StartTransaction;         Result := GetSQLResult();       except        on e: Exception do        begin        WriteLn('Error ', e.Message);        end;      end;    finally    FTransaction.Commit;      FTransaction.Free;      FConnection.Connected := False;      FConnection.Free;    end;  end; ---------------------------------------------------------------------- rvk · 2018-02-22 17:24 @valdir.marcos, the program worked on the server, so I guess everything is set correctly. Quote from: Ferke on February 22, 2018, 12:44:04 pmIf I run my program on the server everything works fine.Ferenc, did you use the same host- settings (i.e. IP of the local network) in the program when testing on the server? With the client installation of Firebird 3.0, do you still get the option on the last page to create a legacy gds32.dll in the Windows- directories? Try a client install with checking that option. I see the TIBConnection first searches for fbclient.dll and then for gds32.dll. But the fbclient.dll is not in the search path and needs to be extracted from registry settings. If that's not done the fbclient.dll can't be found. You could try to copy the fbclient.dll in your program directory but it could be that it needs extra files. (also note that for a 64bit installation the 32bit fbclient.dll is in WOW64) *) So first try the 32bit client install again on the workstation to see if you can install the legacy dll. *) Second, copy the fbclient.dll (make sure you have the correct bitness) to your program directory. *) Third, remove it again and make sure your firebird-bin directory is in the system search path (possible restart required). ---------------------------------------------------------------------- valdir.marcos · 2018-02-22 18:18 @rvk, thanks. @Ferenc, have you set Firebird 3 properly? https://firebirdsql.org/file/documentation/reference_manuals/user_manu als/Firebird-3-QuickStart.pdf https://firebirdsql.org/file/documentation/reference_manuals/user_manu als/html/qsg3-config.html https://www.firebirdsql.org/file/documentation/release_notes/html/en/3 _0/rnfb30-security-new-authentication.html Are you sure you can connect your Firebird 3 server from others computers on your network? Maybe using FlameRobin or similar? http://flamerobin.org/ ---------------------------------------------------------------------- Ferke · 2018-02-22 19:16 Thank you very muck all of you! The biggest problem was that the database aliases do not seem to work for me for an unknown reason. The server runs on Windows 10, and I used this format: mydb = c:\db\db.fdb After using absolute path I found immediately a small fault in my code as well. Anyway, if somebody could help me with the aliases, that would be great. Thank you again!  You have a beer on me! ---------------------------------------------------------------------- rvk · 2018-02-22 19:20 Quote from: Ferke on February 22, 2018, 08:16:41 pmThe biggest problem was that the database aliases do not seem to work for me for an unknown reason. The server runs on Windows 10, and I used this format: mydb = c:\db\db.fdb After using absolute path I found immediately a small fault in my code as well. I never used aliases with Firebird. Why would you want to? Why not just supply the hostname or ip and the absolute path to the database? (I save this in an ini file for my application) ---------------------------------------------------------------------- taazz · 2018-02-22 19:33 Quote from: rvk on February 22, 2018, 08:20:18 pmQuote from: Ferke on February 22, 2018, 08:16:41 pmThe biggest problem was that the database aliases do not seem to work for me for an unknown reason. The server runs on Windows 10, and I used this format: mydb = c:\db\db.fdb After using absolute path I found immediately a small fault in my code as well. I never used aliases with Firebird. Why would you want to? Why not just supply the hostname or ip and the absolute path to the database? (I save this in an ini file for my application) because knowing the full path is both a security bridge and a inelegant implementation. The client application should not know anything about the server environment or at least the absolute minimum to function. ---------------------------------------------------------------------- Ferke · 2018-02-22 19:56 Quote from: taazz on February 22, 2018, 08:33:44 pmQuote from: rvk on February 22, 2018, 08:20:18 pmQuote from: Ferke on February 22, 2018, 08:16:41 pmThe biggest problem was that the database aliases do not seem to work for me for an unknown reason. The server runs on Windows 10, and I used this format: mydb = c:\db\db.fdb After using absolute path I found immediately a small fault in my code as well. I never used aliases with Firebird. Why would you want to? Why not just supply the hostname or ip and the absolute path to the database? (I save this in an ini file for my application) because knowing the full path is both a security bridge and a inelegant implementation. The client application should not know anything about the server environment or at least the absolute minimum to function. This is the reason exactly. And I have to find the solution. ---------------------------------------------------------------------- taazz · 2018-02-22 20:00 Quote from: Ferke on February 22, 2018, 08:56:04 pmThis is the reason exactly. And I have to find the solution. so what does your alias file look like? ---------------------------------------------------------------------- rvk · 2018-02-22 20:15 You did read the release notes for Firebird 3.0, right  https://www.firebirdsql.org/file/documentation/release_notes/html/en/3 _0/rnfb30-compat-aliasesconf.html Quotealiases.conf Is No More The file aliases.conf is replaced by databases.conf in the Firebird root directory. The format for database aliases has not changed so you can copy/paste the contents of your existing aliases.conf file into databases.conf successfully. The new file is capable of carrying a lot more configuration detail, however, to enable database-level configuration of many features that were previously available only at the global server level. ---------------------------------------------------------------------- Ferke · 2018-02-22 20:26 Quote from: taazz on February 22, 2018, 09:00:18 pmQuote from: Ferke on February 22, 2018, 08:56:04 pmThis is the reason exactly. And I have to find the solution. so what does your alias file look like? Hi! No, it was my mistake. I use Firebird on Linux and Windows at the same time for testing purposes. I used slash instead backslash... Still interesting why the slash did not work, since the config file contains this part as vell: # Example Database: # employee.fdb = $(dir_sampleDb)/employee.fdb employee = $(dir_sampleDb)/employee.fdb Anyway, thank you very much! ---------------------------------------------------------------------- taazz · 2018-02-22 21:27 Quote from: rvk on February 22, 2018, 09:15:28 pmYou did read the release notes for Firebird 3.0, right  https://www.firebirdsql.org/file/documentation/release_notes/html/en/3 _0/rnfb30-compat-aliasesconf.html Quotealiases.conf Is No More The file aliases.conf is replaced by databases.conf in the Firebird root directory. The format for database aliases has not changed so you can copy/paste the contents of your existing aliases.conf file into databases.conf successfully. The new file is capable of carrying a lot more configuration detail, however, to enable database-level configuration of many features that were previously available only at the global server level.Nope I haven't installed 3 yet. Thanks for the heads up. ---------------------------------------------------------------------- valdir.marcos · 2018-02-23 01:16 Open the links I have just provided and search for "alias", you will find all information you need. Maybe, you are going through the problem below? Firebird and Windows 10 Fall Creators Update https://www.firebirdsql.org/en/news/firebird-and-windows-10-fall- creators-update/ https://www.ibphoenix.com/resources/documents/general/doc_476