1

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="SQLNET.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
4
  • Is the connection string correct? What's the full exception text? There may be more information in any inner exceptions Commented Aug 24, 2021 at 14:31
  • I can only assume the connection string is correct because it works on the development machine. I'll edit the question to include the exception text. Commented Aug 24, 2021 at 15:03
  • 1
    Do you have a client installed on your dev machine? What about the server? Commented Aug 24, 2021 at 15:20
  • The oracle client is installed on both the dev machine and the server. Commented Aug 24, 2021 at 17:25

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.