Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle .net Provider CommandTimeout not worked

I am trying to change the command timeout for a OracleCommand query, but it is not worked so no timeout exception is not fired.

  • used Oracle.ManagedDataAccess.dll (4.121.2.0)

    using (OracleConnection _connection = new OracleConnection(connectionString))
    {
    
        using(OracleCommand command = _connection.CreateCommand())
        {
    
          command.CommandText = commandText;
          command.CommandTimeout = 10;
    
         _connection.Open();
          using(OracleDataReader reader = command.ExecuteReader())
          {
              while (reader.Read())
              {
                    Console.WriteLine(reader.GetValue(0));
              }
           }
        } }
    

Config:

<configSections>
    <section name="entityFramework"
      type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      requirePermission="false"/>
    <section name="oracle.manageddataaccess.client"
      type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
      <provider invariantName="Oracle.ManagedDataAccess.Client"
        type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client"/>
      <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver"
        type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </DbProviderFactories>
  </system.data>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <publisherPolicy apply="no"/>
        <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>
        <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.121.2.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <oracle.manageddataaccess.client>
    <version number="*">
      <dataSources>
        <dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xxx)(PORT=1561))(CONNECT_DATA=(SERVICE_NAME=xxxx))) "/>
      </dataSources>
    </version>
  </oracle.manageddataaccess.client>
  <connectionStrings>
    <add name="OracleDbContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=xxxx;Password=xxxx;Data Source=SampleDataSource"/>
  </connectionStrings>

This query run more than 10 seconds but no exception fired.

like image 547
Fatih Şimşek Avatar asked Dec 28 '16 05:12

Fatih Şimşek


2 Answers

Oracle .net team solve my problem :)

Seen this problem before with some network config. Try using Disable_Oob=on. More info in README: http://www.oracle.com/technetwork/topics/dotnet/downloads/odpnet-managed-nuget-12102400-2718787.txt …

like image 116
Fatih Şimşek Avatar answered Oct 27 '22 18:10

Fatih Şimşek


Adding the setting Disable_Oob to App.config worked for me:

...
<oracle.manageddataaccess.client>
     <version number="*">
       <settings>
         <setting name="Disable_Oob" value="on" />
       </settings>
       <dataSources> 
    ...
like image 37