1

I am trying to deploy an MVC app to an IIS server with a connection to an Oracle database. To do this I've downloaded the ODAC extension for Visual Studio 2013, as well as used Nuget to install the latest ODP.NET managed client into the project. My development machine also has an Oracle client installed (i.e. I can run SQL Developer on my dev box) but from what I read ODP.NET should not require the Oracle client on the server. However, the app runs fine on my dev box but when deploying to the server I get errors and can't get any Oracle connection to work at all. So far I can't find any useful information on what is causing the errors or how to get around it.

Environment: Visual Studio 2013 Update 5 on 64bit Windows 7, deploying to Windows Server 2008 IIS 7. I do not have administrative rights on the IIS box, it is locked down. The server admin is bending over backwards to help as much as he can but he does not know Oracle, and I know just barely enough to be dangerous. The local Oracle devs all run Java on Linux servers, so I'm the odd .NET/Windows guy with no internal support. Oracle database is 11.2.0.3.0. The web app is in a 64 bit app pool.

IMPORTANT: The Oracle Client is not installed on the IIS box. We aren't sure if a separate Oracle Client must be installed, my readings indicate not but I could be wrong.

What I Need: Ideally a project that can deploy to an arbitrary IIS server and connect to my target Oracle database, without needing any Oracle components/clients installed on the server. I want to be as self-contained as possible, so I can minimize impact on the server as well as be 100% responsible for the configuration management of my app. If I can't be totally self-contained then I need to be able to generate a written document with repeatable steps to configure and deploy to a new IIS server at will, with minimal impact on the server and Oracle admins. Entity Framework would be really nice but not absolutely required -- my "real" app (this one is just a spike to test the connection) currently uses OleDbDataReader objects inside domain repositories, and I will swap them to OracleDataReader once the ODP.NET connection works properly.

Speculation: Currently I'm considering the following causes of the below errors. But I don't know which is the actual cause, so I don't know where to focus my efforts.

  1. Server needs components installed. If so, which ones?

  2. Server is blocked by firewall or not whitelisted by the database server. Firewall should not be an issue per the server admin, not sure about the database whitelist.

  3. ?? Something else ??

Below is a summary of what I have and what I get. Each Action is followed by the error message it generates.

Each of these runs perfectly on my dev box -- the errors are all on the server.

/Home/Index

This is virtually a copy/paste from this Oracle tutorial:

public ActionResult Index()
{
    string conString = "User Id=myuserid;Password=mypassword;" +
        "Data Source=mydomain.foo:1521/myservicename; Pooling=false;";

    OracleConnection con = new OracleConnection();
    con.ConnectionString = conString;
    con.Open();

    return Content("OK");
}

Error Message: ORA-12537: Network Session: End of file

ORA-12537: Network Session: End of file
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: OracleInternal.Network.NetworkException: ORA-12537: Network Session: End of file

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NetworkException (0x30f9): ORA-12537: Network Session: End of file]
   OracleInternal.Network.ReaderStream.ReadIt(OraBuf OB, Int32 len) +294
   OracleInternal.Network.ReaderStream.ReadwithCrypto(OraBuf OB) +127

[NetworkException (0x80004005): ORA-12570: Network Session: Unexpected packet read error]
   OracleInternal.Network.ReaderStream.ReadwithCrypto(OraBuf OB) +1188
   OracleInternal.Network.ReaderStream.Read(OraBuf OB) +88
   OracleInternal.TTC.OraBufReader.GetDataFromNetwork() +274
   OracleInternal.TTC.OraBufReader.Read(Boolean bIgnoreData) +46
   OracleInternal.TTC.MarshallingEngine.UnmarshalUB1(Boolean bIgnoreData) +16
   OracleInternal.TTC.TTCProtocolNegotiation.ReadResponse() +86

[OracleException (0x80004005): ORA-12570: Network Session: Unexpected packet read error]
   OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch) +5643
   OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch) +1381
   OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword) +1583
   Oracle.ManagedDataAccess.Client.OracleConnection.Open() +3837
   OracleClientSpikeMvc.Controllers.HomeController.Oracle() +65
   lambda_method(Closure , ControllerBase , Object[] ) +79
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +242
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +12
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +139
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +112
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +452
   System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +15
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +37
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +241
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

/Home/Oracle

public ActionResult Oracle()
{
    var connectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=myhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=myservicename)));User Id=myuserid;Password=mypassword;";
    var conn = new OracleConnection(connectionString);
    conn.Open();

    var command = conn.CreateCommand();
    command.CommandText = "select sysdate from dual";
    command.CommandType = System.Data.CommandType.Text;
    var reader = command.ExecuteReader();

    if (!reader.HasRows)
        return Content("No rows returned");

    reader.Read();

    return Content(reader["sysdate"].ToString());
}

Error Message: ORA-12537: Network Session: End of file

ORA-12537: Network Session: End of file
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: OracleInternal.Network.NetworkException: ORA-12537: Network Session: End of file

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NetworkException (0x30f9): ORA-12537: Network Session: End of file]
   OracleInternal.Network.ReaderStream.ReadIt(OraBuf OB, Int32 len) +294
   OracleInternal.Network.ReaderStream.ReadwithCrypto(OraBuf OB) +127

[NetworkException (0x80004005): ORA-12570: Network Session: Unexpected packet read error]
   OracleInternal.Network.ReaderStream.ReadwithCrypto(OraBuf OB) +1188
   OracleInternal.Network.ReaderStream.Read(OraBuf OB) +88
   OracleInternal.TTC.OraBufReader.GetDataFromNetwork() +274
   OracleInternal.TTC.OraBufReader.Read(Boolean bIgnoreData) +46
   OracleInternal.TTC.MarshallingEngine.UnmarshalUB1(Boolean bIgnoreData) +16
   OracleInternal.TTC.TTCProtocolNegotiation.ReadResponse() +86

[OracleException (0x80004005): ORA-12570: Network Session: Unexpected packet read error]
   OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch) +5643
   OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch) +1381
   OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword) +1583
   Oracle.ManagedDataAccess.Client.OracleConnection.Open() +3837
   OracleClientSpikeMvc.Controllers.HomeController.Oracle() +65
   lambda_method(Closure , ControllerBase , Object[] ) +79
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +242
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +12
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +139
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +112
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +452
   System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +15
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +37
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +241
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

/Home/EntityFrameworkTest

This uses an EF Code-first context generated from the database:

public ActionResult EntityFrameworkTest()
{
    using (var ctx = new MyContext())
    {
        var list = ctx.MyModel.OrderBy(m => m.MyField).ToList();
        return View(list);
    }
}

Error Message: Connection request timed out

Connection request timed out
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Oracle.ManagedDataAccess.Client.OracleException: Connection request timed out

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[OracleException (0x80004005): Connection request timed out]
   OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch) +5643
   OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch) +1381
   OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword) +1583
   Oracle.ManagedDataAccess.Client.OracleConnection.Open() +3837
   Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices.GetDbProviderManifestToken(DbConnection connection) +234
   System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +118

[ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.]
   System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +459
   System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +40

[ProviderIncompatibleException: An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure.]
   System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +126
   System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +83
   System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) +327
   System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +118
   System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +94
   System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +248
   System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +543
   System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +26
   System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +72
   System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +21
   System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +64
   System.Linq.Queryable.OrderBy(IQueryable`1 source, Expression`1 keySelector) +85
   OracleClientSpikeMvc.Controllers.HomeController.Index() +282
   lambda_method(Closure , ControllerBase , Object[] ) +79
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +242
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +12
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +139
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +112
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +452
   System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +15
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +37
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +241
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

Web.config extracts

<configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <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>

<connectionStrings>
    <add name="MyContext" connectionString="DATA SOURCE=mydatasource;PASSWORD=mypassword;USER ID=myuserid" providerName="Oracle.ManagedDataAccess.Client" />
</connectionStrings>

<dependentAssembly>
    <publisherPolicy apply="no" />
    <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
</dependentAssembly>

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
        <parameters>
        <parameter value="mssqllocaldb" />
        </parameters>
    </defaultConnectionFactory>
    <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>

What do we need to do to eliminate these errors and connect to the Oracle database from the server? Any and all help is much appreciated, thank you!

DaveCan
  • 361
  • 1
  • 5
  • 12
  • can you verify that your oracle user is connecting at all? You should see the entries in the listener.log – kevinskio Oct 28 '15 at 16:08
  • @kevinsky I'll check with the Oracle DBA/SA and see what he can find in the listener.log file. Will update when I get a response, thanks. – DaveCan Oct 28 '15 at 16:23
  • It's not impossible that there is a firewall or other network issue preventing a connection from being made. Can you ping the database from the server? – kevinskio Oct 28 '15 at 16:25
  • I can't access either server, so I've asked the IIS admin to check it out as soon as he has a chance. I do know that both the IIS admin and the DB admin say there should be no firewall or whitelist issues causing a break, but it will be good to prove that. Thanks again. – DaveCan Oct 28 '15 at 16:35
  • @kevinsky the IIS admin reports the ping does get a response from the database server. Still waiting on the DBA to check the listener.log. Thanks for your patience and help. – DaveCan Oct 28 '15 at 18:26
  • @DaveCan, did u solve your problem? – Miguel A. Luna May 24 '17 at 10:32

0 Answers0