OracleClient,间歇性连接问题:应用程序挂在 OracleConnection.Open() 上,没有超时,没有抛出异常
应用程序工作正常,并且每次都可以从除服务器之外的任何计算机进行连接,该服务器应该部署在服务器上:/在服务器上运行时,它可以在大约 20 次或尝试中连接一次。从奇怪的症状来看,我怀疑这是某种与网络配置相关的问题(例如一些随机丢失的数据包?),但我的网络管理员同事尝试了许多不同的设置,但我们无法找到原因/解决方案。
每一条建议都会受到赞赏,因为它真的让我发疯。我想知道切换到 ODP.NET 是否可以解决问题,或者至少可以更轻松地排除故障(我读到 MS 的提供程序不是很稳定)。但由于架构不太灵活,切换起来会花费相当多的时间。但如果这是唯一合理的做法...
我正在使用的一段代码:
DbConnection conn = new OracleConnection();
conn.ConnectionString = _connectionString;
try
{
conn.Open();
DbCommand cmd = conn.CreateCommand();
cmd.CommandText = "select sysdate from dual";
cmd.Connection = conn;
_logger.Info("Sysdate: " + cmd.ExecuteScalar().ToString());
}
catch (OracleException oex)
{
_logger.ErrorException("Oracle exception: " + oex.Message, oex);
}
catch (Exception ex)
{
_logger.ErrorException("Exception: " + ex.Message, ex);
}
finally
{
if (conn != null) conn.Close();
}
更多信息:
- 提供程序:System.Data.OracleClient
- Lib:instantclient-basiclite-win32-10.2.0.3-20061115
- 连接字符串的形式为:
Data Source=ip_address:port_number/instance;Persist Security Info=True;User ID=user;Password=passwd
- 连接没有问题的其他应用程序:使用相同库的 QueryExpress、Sql Developer
- 操作系统:Windows Server 2008标准 SP 2
Application works fine and connects every single time from any machine except the server, where it's supposed to be deployed :/ When run on the server it manages to connect once in like 20 or something attempts. Judging on the funky symptoms, I suspect it to be some kind of a network configuration related issue (as in some randomly lost packets?), but my fellow network administrator tried many different settings and we were not able to find the cause/solution.
Every single piece of advise will be appreciated, as it's seriously driving me nuts. I was wondering if switching to ODP.NET would solve the problem or at least make it easier to troubleshoot (I've read MS's provider is not very stable). However, since the architecture is not very flexible, it would take quite a lot of time to switch. But if it's the only reasonable thing to do...
Piece of code I'm using:
DbConnection conn = new OracleConnection();
conn.ConnectionString = _connectionString;
try
{
conn.Open();
DbCommand cmd = conn.CreateCommand();
cmd.CommandText = "select sysdate from dual";
cmd.Connection = conn;
_logger.Info("Sysdate: " + cmd.ExecuteScalar().ToString());
}
catch (OracleException oex)
{
_logger.ErrorException("Oracle exception: " + oex.Message, oex);
}
catch (Exception ex)
{
_logger.ErrorException("Exception: " + ex.Message, ex);
}
finally
{
if (conn != null) conn.Close();
}
More info:
- Provider: System.Data.OracleClient
- Lib: instantclient-basiclite-win32-10.2.0.3-20061115
- Connection string is of the form:
Data Source=ip_address:port_number/instance;Persist Security Info=True;User ID=user;Password=passwd
- Other apps which connect without a problem: QueryExpress using same libs, Sql Developer
- Os: Windows Server 2008 Standard SP 2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们最终使用了 ODP.NET,因为我们在使用 WCF 将数据从我们的服务传输到 Oracle 时遇到了一些错误问题。我不记得实际的问题了——认为某些东西不适用于某种数据类型——但最终对我们来说效果很好。
We ended up using ODP.NET because of some buggy issues we were having using WCF transferring data from our service to Oracle. I dont recall the actual issue-think something was not working with a certain data type-but it ended up working out pretty well for us.