Reputation: 155
After migrating from Firebird 2.5 to 3.0 this error "connection rejected by remote interface" shows up when I try to test the connection of the database using C# program.
Here is the code for testing the connection, I use this code when I try to connect to the firebird 2.5 database.
txtPassword.Properties.UseSystemPasswordChar = true;
txtHostname.Text = Properties.Settings.Default.server;
txtUsername.Text = Properties.Settings.Default.user;
txtPassword.Text = Properties.Settings.Default.pass;
txtDBPath.Text = Properties.Settings.Default.dbpath;
void Testdbconn()
{
try
{
var testInMemUnicode =
String.Format("DataSource={0};Database={1};User ID={2};Password={3}; Charset=NONE;",
txtHostname.Text,
txtHostname.Text + ":" + txtDBPath.Text.Trim(),
txtUsername.Text,
txtPassword.Text);
var testConnParam = new FbConnection(testInMemUnicode);
testConnParam.Open();
XtraMessageBox.Show(@"Connection to the server is successful.", @"Data Server Test",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
catch (Exception errorCode)
{
XtraMessageBox.Show(@"Error in connection: " + errorCode.Message,
@"Server Error",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
}
class ClsConnection
{
public static string FirebirdSQL = String.Format(
"DataSource={0}; Database={1}; User ID={2}; Password={3}; Charset=NONE; Port=3050; Dialect=3;" +
"Connection lifetime=15; Pooling=true; MinPoolSize=0; MaxPoolSize=2000000; Packet Size=8192; ServerType=0",
Properties.Settings.Default.server, Properties.Settings.Default.db + ":" + Properties.Settings.Default.dbpath,
Properties.Settings.Default.user, Properties.Settings.Default.pass);
private static readonly string FirebirdService = FirebirdSQL;
/// <summary>
///
/// </summary>
public static FbConnection Firebird = new FbConnection(FirebirdService);
/// <summary>
///
/// </summary>
public void Openconnection()
{
if (Firebird.State == System.Data.ConnectionState.Open)
{
Firebird.Close();
}
Firebird.Open();
}
/// <summary>
///
/// </summary>
public void Closeconnection()
{
Firebird.Close();
}
}
Upvotes: 2
Views: 4819
Reputation: 108990
For this answer, I'm assuming you are using a recent Firebird ado.net version (eg 5.12.0.0, but at least 5.0.0.0).
Firebird 3 introduced wire protocol encryption, which is required by default. This encryption is, at the time of writing, not supported by the Firebird ado.net provider. As a result, attempts to connect will fail with the error "connection rejected by remote interface" (error code 335544421).
The solution is to modify the Firebird configuration to only enable, and not require, wire protocol encryption. To do this, edit the firebird.conf
of the Firebird server and change the setting WireCrypt
to WireCrypt = Enabled
(if currently prefixed by a #
, remove the #
), and restart Firebird server. If the Firebird install is in Program Files, you will need to run your editor with administrator privileges to be able to save the file correctly.
Be aware, this error can also occur in other situations where the handshake between client and server cannot agree on some connection and protocol options.
Upvotes: 7