简体   繁体   中英

Oracle.ManagedDataAccess.Client.OracleException (0x80004005): Connection request timed out

I have been struggling with this for a several days. The code runs and connects to the database successfully on my development machine, but when I deploy it to the server, I get this error. I am using Oracle.ManagedDataAccess. This is what I have tried so far.

Checked whether 32bit or 64bit. Turned out to be 64bit Checked TNS Names file. It was correct Checked both machines are on the same.network. They were. Tried creating a stripped down console application that connects to the database. The console application worked on both machines. Main application fails to work on server. Tried creating a stripped down web forms application that connects to the dtabase. The web forms application reproduced the error, ruling out a problem with main application itself. Tried doubling timeout value. Tried decreasing timeout value to 1 second. Tried turning off connection pooling. Tried increasing connection pool size. Tried giving IIS_IUSR full privileges over the Oracle Home directory. Tried rebooting server. Tried <setting name="SQ.NET.AUTHENTICATION_SERVICES" value="null" /> .

Here's the code for the small web application.

        string sql = @"

            SELECT *
            FROM SIMMS_TAB

        ";

        context.Response.ContentType = "text/plain";
        
        int rows = 0;

        try
        {
            using (OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                conn.Open();

                OracleCommand cmd = conn.CreateCommand();

                cmd.CommandType = CommandType.Text;
                cmd.CommandText = sql;

                var reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    rows++;
                }

            }

            context.Response.Write(string.Format("Successfully connected! Found {0} rows.<br />", rows));
        }
        catch (Exception ex)
        {
            context.Response.Write(ex);
        }

The exception text is as follows

Oracle.ManagedDataAccess.Client.OracleException (0x80004005): Connection request timed out
   at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
   at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
   at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, CriteriaCtx criteriaCtx)
   at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
   at StripedDownWebApplication.TestHandler.ProcessRequest(HttpContext context) in C:\Users\mikem\Source\Repos\StripedDownWebApplication\TestHandler.ashx.cs:line 34

In my case, the problem turned out to be very subtle. First of all, the retry_count and the retry_delay of my connection string were set so high that it was timing out retrying the same failed connection over and over again, and thus never showing me the exception that was actually occurring. Once I set them to a more sane value, like 3, I got a different error, a ssl handshake failure. This was then resolved by setting the LoadUserProfile setting in the application pool in IIS to true. After this, the problem went away. It was frustrating, but I hope this helps people who are having this problem in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM