XanderYe的个人小站

解决Linux下ojdbc出现 SQLRecoverableException: IO Error: Connection reset 的问题

问题描述

某个项目需要用java连接jdbc,在部署后发现概率性连不上的问题,一般过段时间前几次都能成功,多试几次就连不上。

https://wp.xanderye.cn/wp-content/uploads/2022/01/image.png

问题原因

连接ORACLE服务器,客户端要生成随机密钥用于客户端认证,linux下JDK默认使用/dev/random,random采用阻塞方式生成随机数,生成的速度很慢,ORACLE服务器会主动reset,并在alert.log中报错:
TNS-12535: TNS:operation timed out
    ns secondary err code: 12606
    nt main err code: 0
    nt secondary err code: 0
    nt OS err code: 0
  Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.6.21)(PORT=33460))
WARNING: inbound connection timed out (ORA-3136)

解决方案

编辑$JAVA_HOME/jre/lib/security/java.securitysecurerandom.source=file:/dev/random 改为file:/dev/urandom(urandom采用非阴塞式生成随机数,性能很好,不会产生超时)

参考

赞赏
没有标签
首页      JAVA      解决Linux下ojdbc出现 SQLRecoverableException: IO Error: Connection reset 的问题

发表评论

textsms
account_circle
email

XanderYe的个人小站

解决Linux下ojdbc出现 SQLRecoverableException: IO Error: Connection reset 的问题
问题描述 某个项目需要用java连接jdbc,在部署后发现概率性连不上的问题,一般过段时间前几次都能成功,多试几次就连不上。 问题原因 连接ORACLE服务器,客户端要生成随机…
扫描二维码继续阅读
2022-01-21