Announcement Announcement Module
No announcement yet.
Connection refused exception in my consumer application Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Connection refused exception in my consumer application


    I am using spring-rabbit 1.1.2.RELEASE version in my producer and consumer application.

    The producer application is working fine and can send messages to the rabbitmq queues without any issue. Bu tye consumer application having issues and print the below warning when the listener getting initialized.

    WARN [SimpleMessageListenerContainer] Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: Connection refused

    When the consumer application starts, both rabbitmq servers are up and running and property values (server name, ports) and passed correctly.

    The spring config as below.
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="" xmlns:xsi=""
        <context:property-placeholder location="file:/app/" ignore-unresolvable="true" />
        <!-- Rabbit MQ connectivity -->
                channel-cache-size="2" />
        <rabbit:admin connection-factory="connectionFactory"/>
        <bean id="jsonConverter" class=""/>
        <bean name="errorHandler" class="biz.hub.queue.RabbitErrorHandler"/>
        <bean id="jsonFactory" class="org.codehaus.jackson.JsonFactory"/>
            <rabbit:listener ref="receiveListner" method="handleMessage" queue-names="${}"/>
        <bean id="receiveListner" class="biz.hub.queue.ConsumerHandler">
            <constructor-arg ref="jsonFactory" />
    Could someone please help me to resolve this issue. Thanks.

  • #2 Connection refused
    This is a low-level TCP exception that means that you are resolving to a host the does not have anything listening on the requested port. The SYN (socket open) is being rejected by the TCP stack on that host.

    So, it seems there is a problem with either the host or port configuration. In either case, you are hitting a real host because the error definitely means you reached a TCP stack where there's no such port listening.

    If you can't figure out your configuration problem, you can use a wire monitor such as WireShark, or tcpdump to take a look at the packets to see what port it's trying to connect to, and on which host.


    • #3
      Thanks Gary for the quick reply. So that means my config file is correct, right ?

      Thanks again.


      • #4
        Also this connection issue comes after I putting the listener configs to the bean xml. Problem is Producer connecting to the same rabbitmq cluster and it works fine.

        Also the telnet from consumer to the rabbitmq servers to port 5672 is fine.

        Any thoughts.

        Many thanks.


        • #5
          Well, it looks ok, but I can't see your properties (and wouldn't know if they are correct if I could).

          I am not a fan of
          in a property-placeholder.

          It's usually better to fail fast.


          • #6
            Hi Gary

            I tried without the ignore-unresolveable option in place holder configuration, but the result is same.

            Forgot to mention the properties in the first post and here they are:
            system.distributed.rabbitmq.username=<user name>

            Please have a look and comment if they are good.

            Also regarding the connection refuse issue, I used the rabbitmq java client and open a connection and it was success. Why this is not success with spring amqp listeners? Is spring amqp using special technique to build up the connection factory?




            • #7
              I don't know if it's good because I don't know your environment.

              Like I said, you are getting a low-level TCP rejection (RST) to the SYN.

              This implies you are connecting to a host that is not listening on the default port.

              I don't think it's a problem parsing the addresses. There is nothing special done to
              build up the connection factory
              ; the addresses attribute is parsed by the underlying Rabbit Client

              At this point, if you don't see anything interesting in DEBUG, or TRACE level logging, I suggest you use wireshark or tcpdump to trace the TCP activity to see what's going on.

              I just ran a test with similar configuration to yours and everything works fine


              • #8
                Thanks Gary.

                I narrow down the problem and not a issue with TCP connections in my network. When building the connection factory I am using

                The property value for the above are app16:5672,app17:5672 in my property file.

                String host = "app16:5672,app17:5672";
                Address[] add = Address.parseAddresses(host);
                The above address line is parsing fine with Address.parseAddresses() method.

                Seems there is problem when pass 2 or more hosts to addresses in connection factory, and it's fine with a single host and a port.

                Any thoughts??


                Last edited by codevally; Sep 18th, 2012, 06:08 PM.


                • #9
                  It's my mistake. I used spring-rabbit 1.0.0 version by mistake and all good with 1.1.2 version. Sorry about the post.