>PROBLEM
Attempt to access the RabbitMQ service, throws the follwing:
Application terminated: factory failed to instantiate due to: Unsupported or unrecognized SSL message.
javax.net.ssl.SSLException: java.net.SocketException: Connection reset
at sun.security.ssl.Alert.createSSLException(Alert.java:127)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:370)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:313)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
at sun.security.ssl.SSLTransport.decode(SSLTransport.java:141)
at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1290)
...
Suppressed: java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
...
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:475)
...
javax.net.ssl.SSLException: java.net.SocketException: Connection reset
at sun.security.ssl.Alert.createSSLException(Alert.java:127)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:370)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:313)
...
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:475)
>SOLUTION
Enable or disable the SSL protocol.
An example of the properties file (application.yml):
rabbit-host: mydomain.com
rabbit-port: 5672
rabbit-ssl: false
rabbit-user: john doe
rabbit-pass: secret
Java code snippet to check the "rabbit-ssl" property:
if (PropertiesYml.BROKER_SSL) {
try {
factory.useSslProtocol();
this.connection = factory.newConnection();
} catch (KeyManagementException | NoSuchAlgorithmException | IOException | TimeoutException e) {
logger.error(String.format("Application terminated: factory failed to instantiate due to: %s.", e.getMessage()));
}
} else {
try {
this.connection = factory.newConnection();
} catch (IOException | TimeoutException e) {
logger.error(String.format("Application terminated: factory failed to instantiate due to: %s.", e.getMessage()));
}
}