"java.sql.SQLException: I/O Error: Connection reset" in linux server

22,741

Answer took from oracle forum, here:

java.security.SecureRandom is a standard API provided by sun. Among various methods offered by this class void nextBytes(byte[]).

This method is used for generating random bytes. Oracle 11g JDBC drivers use this API to generate random number during login. Users using Linux have been encountering SQLException("Io exception: Connection reset").

The problem is two fold:

  1. The JVM tries to list all the files in the /tmp (or alternate tmp directory set by -Djava.io.tmpdir) when SecureRandom.nextBytes(byte[]) is invoked. If the number of files is large the method takes a long time to respond and hence cause the server to timeout

  2. The method void nextBytes(byte[]) uses /dev/random on Linux and on some machines which lack the random number generating hardware the operation slows down to the extent of bringing the whole login process to a halt. Ultimately the the user encounters SQLException("Io exception: Connection reset")

Users upgrading to 11g can encounter this issue if the underlying OS is Linux which is running on a faulty hardware.

The cause of this has not yet been determined exactly. It could either be a problem in the hardware or the fact that for some reason the software cannot read from dev/random

a solution seems to add this setting to the jvm

-Djava.security.egd=file:/dev/./urandom
Share:
22,741
Mohamed Fenni
Author by

Mohamed Fenni

Updated on February 09, 2020

Comments

  • Mohamed Fenni
    Mohamed Fenni over 4 years

    I have a java program which connect to oracle database sometimes it work and sometimes show me this error message :

    Exception in thread "main" java.sql.SQLRecoverableException: IO Error: Connection reset

    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:498)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
    

    How i can solve this problem?