1

I have a pretty strange problem when trying to connect my C# program to an existing Firebird server.

First of all, this is reproducable with the default connection example from the Firebird documentation at https://github.com/FirebirdSQL/NETProvider/blob/master/Provider/docs/ado-net.md

using (var connection = new FBConnection("database=192.168.0.150:c:\\Data\\demo.fdb;user=sysdba;password=m@sterkey"))
{
    connection.Open();
    using (var transaction = connection.BeginTransaction())
    {
        using (var command = new FbCommand("select * from demo", connection, transaction))
        {
            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    var values = new object[reader.FieldCount];
                    reader.GetValues(values);
                    Console.WriteLine(string.Join("|", values));
                }
            }
        }
    }
}

It all works fine when I am on my machine, I also can connect to a Firebird server on my coworkers PC.

But I cannot connect to the Firebird server on my other development server. I found an answer in another question and want to tell you that the server does not have internet access. https://stackoverflow.com/a/57569057/2785084

This is the exception I get:

FirebirdSql.Data.FirebirdClient.FbException: "Unable to complete network request to host " No message for error code 335544721 found."

IscException: Unable to complete network request to host " No message for error code 335544721 found. IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host

I already updated to the latest stable Version of Firebird. I can guarantee that the server is running and no firewall is blocking my connection, because when I try to connect with our old Delphi program, everything works. I also can connect using the lightweight Firebird management tool Flamerobin from Flamerobin.org, which is written in C++, I think.

When I try to connect with DBeaver I get the following message:

[SQLState:28000, ISC error code:335544472] Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

I'm pretty sure that the user and password are correct. I do not use the default password, but a password with an @ sign in it, maybe it has something to do with that.

I now have 2 programs that can Connect (Delphi and C++), and two that cannot connect (C# and Java). Does anyone have any clue or tweak how to change the connection that I can connect to the server?

Mark Rotteveel
  • 82,132
  • 136
  • 114
  • 158
autlunatic
  • 350
  • 3
  • 12
  • From the error message looks like connection problems... Probable networking (firewalls, blocked ports) or server configuration (user/login administration). The DBeaver messsage points to the later. – Cleptus Mar 11 '21 at 07:27
  • That connection string will grive you problems because of the "\" character. You should either `FBConnection(@"database=` or escape that character like `:c:\\Data\\demo.fdb` – Cleptus Mar 11 '21 at 07:29
  • Thanks for your Reply! Sorry i provided a wrong example for the database, of course i used it with double \\ wich also works locally and on my coworkers Pc. I also thought it must be the firewall, but why can i connect with other tools. Is ADO.NET using some special Ports? I cannot understand why DBeaver says it is the wrong User/Password. I checked it 100 times, also i tried connecting to another server with the same credentials. This worked, then i switched the IP to the Old server and it does not work... :/ – autlunatic Mar 11 '21 at 08:02
  • 1
    Are you using Firebird 3? If so, what is the output of `select sec$user_name, sec$plugin from sec$users;` (specifically for the users you're trying)? My guess is that you have a user created using the Legacy_UserManager, while the Firebird ADO.net provider only supports Srp when connecting to Firebird 3, and Jaybird 4 (the Java/JDBC driver) defaults to only using Srp256 and Srp (see also the [Jaybird release notes](https://www.firebirdsql.org/file/documentation/drivers_documentation/java/4.0.x/release_notes.html#default-authentication-plugins)). – Mark Rotteveel Mar 11 '21 at 09:30
  • Also, which version of FirebirdSql.Data.FirebirdClient are you using? – Mark Rotteveel Mar 11 '21 at 09:46
  • Yes I use Firebird 3. FirebirdSql 7.10.1; Output is SYSDBA: Legacy_UserManager and SYSDBA:Srp. It is the same as on the working server. It looks like this is a good point as the old applications only support legacy Auth – autlunatic Mar 11 '21 at 10:36
  • If your old applications use fbclient.dll (which I believe Delphi usually uses), then upgrade them to use a Firebird 3.0 fbclient.dll, and then they will support Srp authentication as well. – Mark Rotteveel Mar 11 '21 at 16:35

1 Answers1

0

Thanks to Mark Rotteveel for the comment which got me to the solution.
I can connect with the default password "masterkey", so it is obvious that the srp user was created with the default credentials and therefore a connection with the other credentials is not possible.

I have to correct the users in my old server. Thanks for the hint that ADO.NET only supports srp.

autlunatic
  • 350
  • 3
  • 12
  • But you have two SYSDBAs so probably you've connected with legacy one which have default password. Disconnection error used to happen if client and server have incompatible settings of WireCrypt/WireCompression. If wire encryption is disabled on server SRP cannot be used. You can check exactly connection parameters including wire settings and used auth plugin with table MON$ATTACHMENT. – user13964273 Mar 11 '21 at 12:59
  • yes exactly, i have two SYSDBA users: the SRP User was with default credentials and the legacy user with my expected password. I tried to connect with SRP but used the legacy credentials, because i thought they are the same. – autlunatic Mar 11 '21 at 14:46
  • 1
    Users exist per authentication plugin, so if a user exists in two authentication plugins, it is important to change the password in both plugins (or better yet, avoid them existing in both, but that is very hard for SYSDBA, because you can't simply drop SYSDBA using the legacy usermanager). – Mark Rotteveel Mar 11 '21 at 16:37