&引用;“远程接口拒绝连接”;在C#程序中连接到Firebird 3
从Firebird 2.5迁移到3.0后,当我尝试使用C#程序测试数据库的连接时,会出现“远程接口拒绝连接”错误 下面是测试连接的代码,我在尝试连接firebird 2.5数据库时使用此代码&引用;“远程接口拒绝连接”;在C#程序中连接到Firebird 3,c#,firebird,firebird-3.0,C#,Firebird,Firebird 3.0,从Firebird 2.5迁移到3.0后,当我尝试使用C#程序测试数据库的连接时,会出现“远程接口拒绝连接”错误 下面是测试连接的代码,我在尝试连接firebird 2.5数据库时使用此代码 txtPassword.Properties.UseSystemPasswordChar = true; txtHostname.Text = Properties.Settings.Default.server; txtUsername.Text = Properties.Settings.Default
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();
}
}
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()
{
尝试
{
var测试码=
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=新的FbConnection(TestInMunicode);
testConnParam.Open();
XtraMessageBox.Show(@“与服务器的连接成功”。,@“数据服务器测试”,
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
捕获(异常错误代码)
{
XtraMessageBox.Show(@“连接错误:”+errorCode.Message,
@“服务器错误”,
MessageBoxButtons.OK,
MessageBoxIcon.感叹号);
}
}
类CLS连接
{
公共静态字符串FirebirdSQL=string.Format(
“数据源={0};数据库={1};用户ID={2};密码={3};字符集=无;端口=3050;方言=3;”+
“连接生存期=15;池=真;MinPoolSize=0;MaxPoolSize=2000000;数据包大小=8192;服务器类型=0”,
Properties.Settings.Default.server,Properties.Settings.Default.db+“:“+Properties.Settings.Default.dbpath,
Properties.Settings.Default.user、Properties.Settings.Default.pass);
私有静态只读字符串FirebirdService=FirebirdSQL;
///
///
///
公共静态FbConnection Firebird=新FbConnection(FirebirdService);
///
///
///
public void Openconnection()
{
if(Firebird.State==System.Data.ConnectionState.Open)
{
Firebird.Close();
}
Firebird.Open();
}
///
///
///
公共连接()
{
Firebird.Close();
}
}
对于这个答案,我假设您使用的是最新的Firebird ado.net版本(例如5.12.0.0,但至少是5.0.0.0)
Firebird 3引入了有线协议加密,这在默认情况下是必需的。在编写本文时,Firebird ado.net提供程序不支持此加密。因此,尝试连接将失败,错误为“远程接口拒绝连接”(错误代码335544421)
解决方案是修改Firebird配置,使其仅启用而不需要有线协议加密。为此,请编辑firebird服务器的firebird.conf
,并将设置WireCrypt
更改为WireCrypt=Enabled
(如果当前前缀为#
,请删除#
),然后重新启动firebird服务器。如果Firebird安装在程序文件中,则需要以管理员权限运行编辑器才能正确保存文件
请注意,在客户端和服务器之间的握手无法就某些连接和协议选项达成一致的其他情况下,也会发生此错误。对于此答案,我假设您使用的是最新的Firebird ado.net版本(例如5.12.0.0,但至少是5.0.0.0) Firebird 3引入了有线协议加密,这在默认情况下是必需的。在编写本文时,Firebird ado.net提供程序不支持此加密。因此,尝试连接将失败,错误为“远程接口拒绝连接”(错误代码335544421) 解决方案是修改Firebird配置,使其仅启用而不需要有线协议加密。为此,请编辑firebird服务器的
firebird.conf
,并将设置WireCrypt
更改为WireCrypt=Enabled
(如果当前前缀为#
,请删除#
),然后重新启动firebird服务器。如果Firebird安装在程序文件中,则需要以管理员权限运行编辑器才能正确保存文件
要知道,,在客户端和服务器之间的握手无法就某些连接和协议选项达成一致的其他情况下,也会发生此错误。您使用的Firebird ado.net提供程序的哪个版本?您使用的Firebird ado.net提供程序的哪个版本?仅为了测试,可以完全关闭fb 3最新协议功能:AuthServer=Legacy\u Auth,AuthClient=Legacy\u Auth,UserManager=Legacy\u UserManager,WireCrypt=Disabled,WireCompression=false@AndrejKireje当然可以,但在这种情况下,设置
WireCrypt=Enabled
的侵入性最小,允许确实支持加密的客户端使用加密进行连接。我还认为禁用SRP不是最好的选择,只有在没有其他选择的情况下才应该这样做。如果您确实需要它,应该在Srp
旁边添加Legacy\u Auth
。仅为了测试,您可以完全关闭fb 3最新的协议功能:AuthServer=Legacy\u Auth,AuthClient=Legacy\u Auth,UserManager=Legacy\u UserManager,WireCrypt=Disabled,WireCompression=false@AndrejKireje当然可以,但在这种情况下,设置WireCrypt=Enabled
的侵入性最小,允许确实支持加密的客户端使用加密进行连接。我也认为