11

Am seeing the below error while trying to connect to Oracle 11g on Red Hat Linux, 64-bit using thin jdbc drivers. Would highly appreciate if anyone can throw more light on how to go about troubleshooting this.

 Caused by: java.net.SocketException: Connection reset
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at oracle.net.ns.DataPacket.send(DataPacket.java:199)
    at oracle.net.ns.NetOutputStream.flush(NetOutputStream.java:211)
    at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:227)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:175)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:100)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:85)
    at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:123)
    at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:79)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1122)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1099)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:288)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
    at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:366)
    at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:752)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:366)
John C
  • 1,795
  • 4
  • 27
  • 42

6 Answers6

15

We've had something very similar, moved a program from 32-bit to 64bit OS & a number of concurrent processes would throw the IO Error: Connection Reset.

Stumbled across this which fixed it:

https://community.oracle.com/message/3701989

Basically add the -Djava.security.egd=file:/dev/./urandom parameter and it's good to go :)

DotMasta
  • 186
  • 1
  • 3
7

You didn't include any details of the problem like what changed? Is this a new configuration for you or did it suddenly stop working? Do you know if you have enough connections available? Does this happen to every connection or is it intermittent?

Considering the error is occurring during the logon process, a few possibilities are:

  1. Network fault
  2. You have exhausted the maximum # of connections, so Oracle hangs up on you.
  3. Firewall restrictions
  4. A problem with the database server or the listener. The processing serving your session could be crashing after it's opened.

Check the following stackoverflow thread about how to check the number of active connections and the max. I would expect an "ORA-00018: maximum number of sessions exceeded" error if that were the problem, so it may not be. But it's worth checking.

How to check the maximum number of allowed connections to an Oracle database?

Community
  • 1
  • 1
Brandon
  • 9,822
  • 3
  • 27
  • 37
  • What changed was the oracle ojdbc jars. It is somewhat intermittent like if i were to run the batch job manually, most of the time it works fine but when it executes via cron scheduler, i see the above error. – John C Mar 17 '13 at 19:49
  • 1
    Are the connections pooled? Trying to see if all connections are identical. – Brandon Mar 17 '13 at 19:53
  • For whatever it's worth, the problem only happens on Red hat linux, works fine on Windows. – John C Mar 17 '13 at 19:55
  • 1
    Ok, check the network configuration on the Linux machine. If it were an existing connection, I'd suspect an idle socket timeout. But since it occurs when the connection is started, it must be something else. If the machine is not publicly facing, can you disable iptables temporarily to see if the problem goes away? – Brandon Mar 17 '13 at 19:59
  • Ok, i will let you know of the outcome. – John C Mar 17 '13 at 22:32
  • So what was the outcome? how could you get it resolved? – mostafa.S Jan 04 '15 at 14:11
  • 3
    I could get it resolved by adding this parameter to the Hotspot JVM: -Djava.security.egd=file:/dev/./urandom – mostafa.S Jan 04 '15 at 15:39
  • @mostafa.S what is the windows equivalent to it? – Gaurav Apr 15 '19 at 16:34
7

I faced similar issue with Sqoop Oracle import and I have implemented the fix suggested by this link

This setting helped to resolve issue:

-Dmapred.child.java.opts="-Djava.security.egd=file:///dev/urandom"

and I've changed mapred-site.xml configuration property name value as:

mapreduce.admin.map.child.java.opts -Djava.security.egd=file:///dev/urandom

This is a bit sqoop specific, but I think setting JVM option -Djava.security.egd=file:///dev/urandom" will help you to resolve issue.

Konstantin V. Salikhov
  • 4,554
  • 2
  • 35
  • 48
akshat thakar
  • 1,445
  • 21
  • 29
  • 1
    this is the right answer which worked for me like a charm; although I used this: -Djava.security.egd=file:/dev/./urandom – mostafa.S Jan 04 '15 at 15:36
2

Since the stack does not indicate any ORAs, you have underlying network problems.

Michael-O
  • 18,123
  • 6
  • 55
  • 121
  • Could it be related to not having the proper platform specific ojdbc jar. Where would i find the right ojdbc jar for Oracle 11g? Also, what would be a way to begin troubleshooting the network problem? – John C Mar 17 '13 at 19:37
  • 1
    No, the Net8 protocol is always the same. Obtains 11.2.0.3.0 drivers from the Oracle website. – Michael-O Mar 17 '13 at 19:39
  • Is that always the case where if there is no ORAs it is a network issue? Can the ORAs be omitted for some reason and may not be seen? – Navigatron Dec 18 '14 at 11:06
  • @Navigatron, I cannot tell but this is my observation. You should be able to see the same in the Oracle trace files. – Michael-O Dec 18 '14 at 12:03
1

Other thing that was causing me this problem was having the HOSTNAME settings wrong. My connection attempt was hanged at:

"main" prio=10 tid=0x00007f7cc8009000 nid=0x2f3a runnable [0x00007f7cce69e000]
   java.lang.Thread.State: RUNNABLE
        at java.net.Inet4AddressImpl.getLocalHostName(Native Method)
        at java.net.InetAddress.getLocalHost(InetAddress.java:1444)
        at sun.security.provider.SeedGenerator$1.run(SeedGenerator.java:176)
        at sun.security.provider.SeedGenerator$1.run(SeedGenerator.java:162)
        at java.security.AccessController.doPrivileged(Native Method)

So make sure you have an entry for your hostname in /etc/hosts/.

If you issue a hostname command like this:

$ hostname
my.server.com

You need a line in your /etc/hosts:

127.0.0.1 my my.server.com
Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
0

In my application, I was creating BasicDataSource twice & it was failing with java 1.8 32 bit. Issue got resolved when I moved to java 1.8 64 bit