【问题标题】:Getting Error: "underlying connection closed: unexpected error on request receive"出现错误:“基础连接已关闭:请求接收时出现意外错误”
【发布时间】:2012-01-25 07:01:36
【问题描述】:

我正在使用带有 Web 服务 (.net) 和 oracle 数据库的 .Net 应用程序。但是当我向服务器发送一些请求并等待结果时,它会给出以下错误

底层连接已关闭:发生意外错误

我无法找到错误的原因。任何人都可以帮助我了解此错误的实际原因以及我需要做的解决方案。此错误仅在生产服务器中发生。开发和测试服务器中的相同代码正在运行。

【问题讨论】:

  • 检查数据库是否正在运行并且可以从 .Net Accplicatoin 访问,连接字符串是正确的。还要放更多关于错误的信息,寻找内部异常。
  • 查看this文章。
  • 正常运行到5分钟...如果请求超过5分钟就会出现这个错误
  • 检查与数据库服务器的活动连接数,可能是您没有关闭它们,在生产中使用率很高,这会导致问题
  • 如何检查这个??我在 PRO 服务器中也无权访问

标签: c# .net web-services oracle


【解决方案1】:

这可能是由您正在调用的 Web 服务方法或函数内部的错误引起的。只需创建适当的错误处理并记录 Web 服务异常。这是我的示例代码:

    [WebMethod]
    public void MyServerMethod()
    {
        try
        {
            //open connection and execute your calls to Oracle DB...
        }
        catch (Exception ex)
        {
            LogServiceException(ex);
            throw ex;
        }
    }

    void LogServiceException(Exception ex)
    {
        string fullMessage = ex.Message;
        while (ex.InnerException != null)
        {
            ex = ex.InnerException;
            fullMessage += " Inner exception: " + ex.Message;
        }
        //log your exception to log file, DB or eventlog...
        //in this case I will use log file, just make sure you appropriate filesystem rights to do this...
        System.IO.File.AppendAllText("LogFile.txt", fullMessage);
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    • 2018-03-29
    • 2019-03-01
    相关资源
    最近更新 更多