1

I am attempting to create a client/server using the SSL communication. I followed the instructions listed here (https://www.rabbitmq.com/ssl.html).

I am greeted with this error:

while running the server :

java.net.SocketException: Connection reset
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at java.io.DataOutputStream.flush(DataOutputStream.java:123)
    at com.rabbitmq.client.impl.SocketFrameHandler.sendHeader(SocketFrameHandler.java:129)
    at com.rabbitmq.client.impl.SocketFrameHandler.sendHeader(SocketFrameHandler.java:134)
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:277)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:678)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:722)

while using the client :

Exception in thread "main" java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at sun.security.ssl.InputRecord.readFully(Unknown Source)
    at sun.security.ssl.InputRecord.read(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.waitForClose(Unknown Source)
    at sun.security.ssl.HandshakeOutStream.flush(Unknown Source)
    at sun.security.ssl.Handshaker.kickstart(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.kickstartHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    at java.io.DataOutputStream.flush(Unknown Source)
    at com.rabbitmq.client.impl.SocketFrameHandler.sendHeader(SocketFrameHandler.java:129)
    at com.rabbitmq.client.impl.SocketFrameHandler.sendHeader(SocketFrameHandler.java:134)
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:277)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:678)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:722)
    at rmqClient.simpleSSL.main(simpleSSL.java:23)

here's my rabbit.config file :

[
    {ssl, [{versions, ['tlsv1.2', 'tlsv1.1']}]},
    {
    rabbit,
    [
          {ssl_listeners, [5675]},
      {ssl_options, [{cacertfile,"sslConn/ca_certificate.pem"},
                          {certfile,  "sslConn/server_certificate.pem"},
                          {keyfile,   "sslConn/server_key.pem"},
                          {versions, ['tlsv1.2', 'tlsv1.1']},
                          {ciphers,  [{ecdhe_ecdsa,aes_128_cbc,sha256},
                                      {ecdhe_ecdsa,aes_256_cbc,sha}]}
                         ]},     
          {tcp_listeners, [5672]},
          {loopback_users, []}
        ]
    }
].

here's also my client code :

    factory.setHost("10.3.9.139");
    factory.setPort(5673);
    factory.setUsername("User1");
    factory.setPassword("User1");
    factory.useSslProtocol();
    Connection conn = factory.newConnection();
    Channel channel = conn.createChannel();
    channel.queueDeclare("rabbitmq-java-test", false, true, true, null);
    channel.basicPublish("", "rabbitmq-java-test", null, "Hello, World".getBytes());

3 Answers 3

4

java.net.SocketException: Connection reset is generally speaking caused by remote peer closed connection.

I guess your SSL config didn't fit well with server. Suggestion here is to debug SSL connection to find root cause.

Try to append this system property to your JVM params:

-Djavax.net.debug=all

More details here

Sign up to request clarification or add additional context in comments.

3 Comments

I am getting same error when trying to hit from soapui.. Can you please let me know that where do i need to add -Djavax.net.debug=all?
I have added in SoapUI-5.0.0.vmoptions.. Let me see i am able to resolve the issue. I did not get any clue.. getting same errorlog..
I wish I'd known about -Djavax.net.debug=all about 5 weeks ago! If you're using Tomcat, you'll need to find the right place in catalina.sh to add it.
1

I was able to fix this in Java 1.7 by specifying: SSLContext sc = SSLContext.getInstance("TLSv1.2");

Comments

0

In the v configuration you have set port 5675 for SSL listener, but in code you are using 5673.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.