1
votes

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?

1
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
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
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
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). - Mark Rotteveel
Also, which version of FirebirdSql.Data.FirebirdClient are you using? - Mark Rotteveel

1 Answers

0
votes

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.