Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSLException: closing inbound before receiving peer's close_notify

Tags:

java

mysql

jdbc

I'm writing a simple JDBC code with MySQL. Everything works fine and I'm able to print the records in table through select statement. But when I'm closing the connection, using Connection.close(), I'm getting the below exception. Any help is appreciated.

 WARN: Caught while disconnecting...
EXCEPTION STACK TRACE:
** BEGIN NESTED EXCEPTION ** 
javax.net.ssl.SSLException
MESSAGE: closing inbound before receiving peer's close_notify
 STACKTRACE:
 javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:129)
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:255)
    at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:645)
    at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:624)
    at com.mysql.cj.protocol.a.NativeProtocol.quit(NativeProtocol.java:1312)
    at com.mysql.cj.NativeSession.quit(NativeSession.java:182)
    at com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:1750)
    at com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java:720)
    at com.jdbc.Driver.display(Driver.java:27)
    at com.jdbc.Driver.main(Driver.java:38)
like image 974
JasonD Avatar asked Dec 16 '18 14:12

JasonD


2 Answers

This was a issue with the MySQL driver on Java 11 https://bugs.mysql.com/bug.php?id=93590

This has been fixed in Connector/J version 8.0.16

like image 182
Jacob Ellis Avatar answered Oct 22 '22 08:10

Jacob Ellis


Another workaround is to disable SSL by appending ?useSSL=false to the JDBC URL.

jdbc:mysql://localhost:port/database_name?useSSL=false
like image 1
Gayan Weerakutti Avatar answered Oct 22 '22 06:10

Gayan Weerakutti