Oracle connectivity issues with dotnet on linux

0

I'm trying to connect to an Oracle DB from a C# dotnet Core 2.2 microservice on a Linux box. It's throwing an "Unable to resolve connect hostname" error, ORA-12545. I'm trying to avoid using IP address to connect, and can't have the Oracle client installed on this box, which I suspect would be the easy fix. I should mention that connecting directly to the IP DOES work on Linux, only the hostname is failing to connect.

The connection works just fine when run on a local windows machine, without an Oracle client installed. I've tried a few versions of the ODP.NET Core package, to no avail. The linux machine is a Red Hat 7.7 box. I've tried adding the ip/hostname to the /etc/hosts file. nslookup on the hostname works just fine.

The offending code is fairly straightforward:

string sConnectionString = $"User Id={sUserId};Password={sPassword};Data Source={sHost}:1521/{sServiceName};";
_logger.LogI(sConnectionString);

OracleConnection con = new OracleConnection(sConnectionString);//Dies here on Linux.

System.Console.WriteLine(con.State.ToString());

OracleCommand cmd = con.CreateCommand();

Error: Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-12545: Network Transport: Unable to resolve connect hostname ---> OracleInternal.Network.NetworkException (0x80004005): ORA-12545: Network Transport: Unable to resolve connect hostname ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000001, 11): Resource temporarily unavailable

Any ideas would be great, I'm running out of them!

.net
oracle
redhat
connectivity
asked on Stack Overflow Oct 23, 2019 by Niall • edited Oct 24, 2019 by Niall

1 Answer

0

The issue was that the linux box was on a different domain than the oracle box. A non-prod vs prod type thing. The non-prod linux box was receiving a shortened version of a hostname back from oracle on the initial connection attempt. Windows boxes were resolving this fine because they are on the same domain as the oracle box. Updating /etc/resolve.conf on the linux box to look at both domains in it's searching has fixed the problem. Ideally, oracle would return fully qualified hostnames in this scenario, but this will work too!

answered on Stack Overflow Oct 24, 2019 by Niall

User contributions licensed under CC BY-SA 3.0