似乎无法让 Firebird 连接到本地 IP 地址
我在几个使用 Firebird 和 .net 的客户端站点上遇到了一个奇怪的问题。我正在使用 firebird 2.1 和 Visual Studio 的 DDEX Provider,并且我正在使用 c# 工作。具体来说,我得到了一个非常普遍的例外情况,如下:
Exception on trying to connect to firebird DB:
FirebirdSql.Data.FirebirdClient.FbException: Unable to complete network request to host "10.206.34.177".
---> FirebirdSql.Data.Common.IscException: Exception of type 'FirebirdSql.Data.Common.IscException' was thrown.
at FirebirdSql.Data.Client.Gds.GdsConnection.Connect(String dataSource, Int32 port, Int32 packetSize, Charset charset)
at FirebirdSql.Data.Client.Gds.GdsDatabase.Attach(DatabaseParameterBuffer dpb, String dataSource, Int32 port, String database)
at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect()
--- End of inner exception stack trace ---
at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect()
at FirebirdSql.Data.FirebirdClient.FbConnectionPool.Create()
at FirebirdSql.Data.FirebirdClient.FbConnectionPool.CheckOut()
at FirebirdSql.Data.FirebirdClient.FbConnection.Open()
at Seljax.Database.Firebird.DatabaseManager.TryToConnect()
在我看来,这表明网络存在问题,也许是防火墙或类似的东西?但我似乎找不到该块?
更多信息(2 个不同的案例):
案例 1(网络 1):
Windows 7 x64 计算机,运行 service pack 1。我已将 firebird 配置为使用 5013 端口,如果我指定本地环回地址( 127.0.0.1)。此外,它还可以很好地连接本地 IP 地址 (10.206.34.177),该地址当前配置为 satic,网络掩码为 255.255.255.192。但是,如果我将这台计算机更改为使用动态 IP 地址(从 DHCP 服务器获取),并尝试连接到该 IP(在本例中我得到 10.206.34.184 掩码 255.255.255.192),则会出现上述异常。据我所知,除了使用静态 IP 之外,我的配置与 DHCP 服务器提供的配置相同。除此之外,我还尝试了以下方法来使其与动态 IP 地址一起使用: - 关闭Windows防火墙 - 关闭微软安全必需品(实时保护) - 关闭防火墙和MSE - 确保用户帐户控制设置为最小 - 从网络配置中禁用 IPV6
据我所知,网络设置为不过滤任何类型的内部网络流量。我可以很好地 ping 本地系统。我有一个简单的程序,使用 c# 的 TcpClient 类打开一个到系统的套接字,它可以很好地连接到 ip 和端口,我认为这意味着建立了一个套接字连接,这“似乎”表明它可以工作。
请注意,我已尽我所能,找不到安装在 microsoft security essensial 和内置防火墙之外的任何其他防病毒软件或防火墙。
完全不知所措,请给点建议?
案例 2(网络 2):
Windows 7 x32 计算机,无 SP1。我已将 firebird 端口配置为 3050。我什至无法使用环回地址(127.0.0.1)连接到这台机器。我尝试过静态、非静态、禁用IPV6、禁用防火墙和禁用MSE。本机的 IP:10.200.81.179 掩码 255.255.255.192。
更新 - 在将网络上的所有三台机器更改为使用静态 IP 地址后,这台机器现在可以连接到自身,但出现了一个新问题,如下所示
再次,完全不知道想法,请提出建议?
更多信息: 我已经设置了一个疯狂的简单测试程序,它有 3 个文本框,我可以填充这些文本框来连接到数据库,并且我已经确认它在 firebird 运行时确实按预期工作,并且在不运行时它会生成完全相同的错误我上了clinet机器。
例如,您启动 firebird 服务,运行连接,成功,关闭服务,运行连接,上面的异常,以及 FbException 中的所有其他异常将与我尝试连接的机器的异常相匹配。
我通过单击按钮完成了所有代码设置,无论如何,作为参考,将导致异常的代码在这里:
// setup connection
FbConnectionStringBuilder csb = new FbConnectionStringBuilder();
csb.DataSource = firebirdAddress.Text;
csb.Port = Convert.ToInt32(firebirdPort.Text);
csb.Database = firebirdPath.Text;
csb.ServerType = 0;
csb.UserID = "SYSDBA";
csb.Password = "masterkey";
csb.Dialect = 3;
// generate the conneciton object
string connectionString = csb.ToString();
FbConnection connection = new FbConnection(connectionString);
try
{
MessageBox.Show("Trying to connect with string: " + Environment.NewLine + connectionString);
connection.Open();
MessageBox.Show("Firebird connected successfully!");
}
catch ( Exception exception)
{
FbException fireException = (FbException) exception;
for ( int i = 0; i < fireException.Errors.Count; i++ )
{
MessageBox.Show("Class: " + fireException.Errors[i].Class.ToString() + Environment.NewLine +
"Error #" + fireException.Errors[i].Number.ToString() + ": " + fireException.Errors[i].Message + " on line " +
fireException.Errors[i].LineNumber.ToString() );
}
MessageBox.Show("Exception caught: " + Environment.NewLine + exception.ToString());
// loop through all inner exceptions
while ( exception.InnerException != null )
{
MessageBox.Show("Inner exception: " + Environment.NewLine + exception.InnerException.ToString());
exception = exception.InnerException;
}
}
finally
{
connection.Close();
connection = null;
connectionString = null;
csb = null;
}
无论如何,任何建议或信息都将非常适用!
一些更多的信息已经曝光,在上面的情况 1 中,我能够使用 Windows XP 计算机成功连接到计算机,并使用上面显示的用于连接的代码。
Windows 是否对 ip 路由做了一些奇怪的事情?
更新: 情况 2 中无法连接到 127 地址的计算机已通过将网络上的所有计算机更改为使用静态 IP 地址来“修复”。然而案例2变得更有趣了。 senario里有三台电脑。这三个现在可以“某种程度”进行通信,因为它们都设置为静态 IP。
Details of communication:
Computer A Computer B Computer C
works works doesn't work Computer A
works works doesn't work Computer B
doesn't work works works Computer C
显而易见的答案是将服务器放在计算机 B 上并与它一起使用,但它在逻辑上不起作用,因为该计算机是一台非常差的机器,并且很少打开。注意,这三个都运行 Windows 7
分辨率: 上面的情况2,一些计算机无法与其他计算机通信,并且涉及3台计算机,结果是网络上有2台同名计算机。我最好的猜测是 windows 或 firebird 或两者都以某种方式依赖于通信的名称,而重复的名称阻止了它。
对于情况 1,我们采用的解决方案只是将计算机保留为静态 IP 地址。不知道为什么这是必要的,但它确实解决了问题。此外,该网络上还有第二台机器,也是 Windows 7,如果没有静态 IP 地址,则无法正确连接。
I'm having a strange issue on a couple of client sites with Firebird and .net. I am using firebird 2.1 and the DDEX Provider for visual studio, and I'm working in c#. Specificaly I'm getting a very general exceptions as follows:
Exception on trying to connect to firebird DB:
FirebirdSql.Data.FirebirdClient.FbException: Unable to complete network request to host "10.206.34.177".
---> FirebirdSql.Data.Common.IscException: Exception of type 'FirebirdSql.Data.Common.IscException' was thrown.
at FirebirdSql.Data.Client.Gds.GdsConnection.Connect(String dataSource, Int32 port, Int32 packetSize, Charset charset)
at FirebirdSql.Data.Client.Gds.GdsDatabase.Attach(DatabaseParameterBuffer dpb, String dataSource, Int32 port, String database)
at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect()
--- End of inner exception stack trace ---
at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect()
at FirebirdSql.Data.FirebirdClient.FbConnectionPool.Create()
at FirebirdSql.Data.FirebirdClient.FbConnectionPool.CheckOut()
at FirebirdSql.Data.FirebirdClient.FbConnection.Open()
at Seljax.Database.Firebird.DatabaseManager.TryToConnect()
This would seem to me to indicate an issue with the network, perhaps a fire wall or somthing of that sort in place? And yet I can't seem to find the block?
More information (2 distinct cases):
Case 1 (network 1):
Windows 7 x64 computer, running service pack 1. I have configured firebird to use a port of 5013, and it connects just fine with if I specify the local loopback address (127.0.0.1). Further it connects just fine the the local IP Adress (10.206.34.177) which is currently configured as satic with a netmask of 255.255.255.192. However, if I change this computer to use a dynamic IP address (fetched from the DHCP server), and try to connect to the IP (in this case I was getting 10.206.34.184 mask 255.255.255.192) I get the exception above. As best I can tell, I've configured everything the same as what the DHCP server provides, except using a static IP. Further to all of this, I've tried the following to make it work with the Dynamic IP Address:
- turned off the windows firewall
- turned off microsoft secuirty essencials (realtime protection)
- turned off both firewall and MSE
- ensured the the user account controls are set to minimum
- Disabled IPV6 from the network configuration
As best as I can tell, the network is setup to not filter any sort of internal network traffic. I can ping the local system just fine. I have a simple program that opens a socket to the system using c#'s TcpClient class and it connects just fine to the ip and port, which I think means that a socket connection is established, which would "seem" to indicate that it would work.
Note, I've looked as best I can I wasn't able to find any other antivirus or firewalls installed outside of microsoft security essensial, and the built in firewall.
Totaly at a loss, suggestions please?
Case 2 (network 2):
Windows 7 x32 computer, No SP1. I've left the firebird port configured to 3050. this machine I can't even connect to using the loopback address (127.0.0.1). I've tried static, non-static, disabling IPV6, disabling firewall, and disabling MSE. IP for this machine: 10.200.81.179 mask 255.255.255.192.
Update - this machine can now connect to itself, after changing all three machiens on the network to use static IP Addresses, but a new problem presented, listed below
Again, totaly at a loss for ideas, suggestions please?
Even more infomration:
I've setup a crazy simple test program that has 3 text boxes that I can populate to connect to the database with, and I've confimed it does work as expected with firebird running, and with is not running it generates the exact same errors I get on the clinet machines.
So for example you start the firebird service, run the connect, success, shut down the service, run the connect, and the exception above, and all the other exceptions from the FbException will match that of the machines I'm trying to connect to.
I have all the code setup on a button click, anyway, for reference the code that will cause the exception is here:
// setup connection
FbConnectionStringBuilder csb = new FbConnectionStringBuilder();
csb.DataSource = firebirdAddress.Text;
csb.Port = Convert.ToInt32(firebirdPort.Text);
csb.Database = firebirdPath.Text;
csb.ServerType = 0;
csb.UserID = "SYSDBA";
csb.Password = "masterkey";
csb.Dialect = 3;
// generate the conneciton object
string connectionString = csb.ToString();
FbConnection connection = new FbConnection(connectionString);
try
{
MessageBox.Show("Trying to connect with string: " + Environment.NewLine + connectionString);
connection.Open();
MessageBox.Show("Firebird connected successfully!");
}
catch ( Exception exception)
{
FbException fireException = (FbException) exception;
for ( int i = 0; i < fireException.Errors.Count; i++ )
{
MessageBox.Show("Class: " + fireException.Errors[i].Class.ToString() + Environment.NewLine +
"Error #" + fireException.Errors[i].Number.ToString() + ": " + fireException.Errors[i].Message + " on line " +
fireException.Errors[i].LineNumber.ToString() );
}
MessageBox.Show("Exception caught: " + Environment.NewLine + exception.ToString());
// loop through all inner exceptions
while ( exception.InnerException != null )
{
MessageBox.Show("Inner exception: " + Environment.NewLine + exception.InnerException.ToString());
exception = exception.InnerException;
}
}
finally
{
connection.Close();
connection = null;
connectionString = null;
csb = null;
}
Anyway, any suggestions or information would be very appricated!
Some more information has come to light, in case 1 above I am successfully able to connect to the computer using a windows XP machine and the code displayed above for getting connected.
Is windows doing something strange with the ip routing??
Update:
The computer in case 2 not being able to connect to the 127 address has been "fixed" by changing all the machine on the network to use a static IP address. however case 2 has become more interesting. There are three computers in the senario. The three can "sortof" comunicate now as they are all set to static IPs.
Details of communication:
Computer A Computer B Computer C
works works doesn't work Computer A
works works doesn't work Computer B
doesn't work works works Computer C
The obvious answer would be to put the server on computer B and go with it, but it doens't work logisticaly, as that computer is a very poor machine, and is rarely on. Note, all three are running windows 7
Resolution:
The case 2 above where some computers couldn't talk to others and there were 3 machines involved, turned out to be that there were 2 computer with the same name on the network. My best guess is that windows, or firebird, or both somehow depend on the name for communictaion, and the duplicate name was blocking it.
In case 1 the resolution we went with is simply to keep the machine as a static IP address. Not sure why this is nessicary, but it does fix the problem. further there is a second machine on this network that is also windows 7 and would not connect correctly without having a static IP Address.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您评论中发布的信息,我认为您的问题可能是以下之一:
RemoteBindAddress
您可以使用
netstat -a
命令检查 Firebird 是否正在侦听该端口。此输出意味着 Firebird 正在侦听所有接口:
此时它专门侦听 127.0.0.1 中的
3050 是默认端口,请检查您正在侦听的正确端口
As the info posted in your comments, I think your problem may be one of these:
RemoteBindAddress
of your firebird.conf fileYou can check if Firebird is listening at the port with the
netstat -a
command.This output means Firebird is listening on all interfaces:
while this is when it's listening a specifically in 127.0.0.1
3050 is the default port, check for the right port you're listening on
好吧,在案例 2 中,问题出在网络上有两台同名的计算机!
现在我对这个问题的简单性和由此产生的奇怪症状感到有点疯狂。
我不确定这是如何或为什么会出现这种情况,但现在已经解决了。明天我会检查案例 1。
作为参考案例 1 和案例 2,位于两个独立的网络上。
Okay, so in Case 2, the problem turned out to be there were two computers on the network with the same name!!!
I'm a bit beside myself right now with the simplicity of the problem and the weird symptoms this was generating.
I'm not sure how or why this was the case, but it's fixed now. I will be checking on Case 1 tommorrow.
For refrence case 1 and case 2 where, on two seperate networks.