Warning - closing AMQP connection

1,520 views
Skip to first unread message

Barry von Tobel

unread,
Sep 11, 2019, 10:44:43 PM9/11/19
to rabbitmq-users
I apologize, but being a newbie at rabbitmq, and not really a java programmer i'm struggling here.
I have been going through the tutorials and my connection closes when i run the ReceiveLogsTopic.java tutorial.  below is the java output  and some code snippet

bvt@study:~/Dropbox/work/rabbitmq$ java ReceiveLogsTopic.java
Usage: ReceiveLogsTopic [binding_key]...
------------------------------------
if (argv.length < 1) {
            System.err.println("Usage: ReceiveLogsTopic [binding_key]...");
            System.exit(1)
----------------------------------------
the rabbitmq log,

=INFO REPORT==== 12-Sep-2019::02:16:15 ===
accepting AMQP connection <0.27230.0> (99.177.222.248:43706 -> 172.31.12.178:5672)

=INFO REPORT==== 12-Sep-2019::02:16:15 ===
connection <0.27230.0> (99.177.222.248:43706 -> 172.31.12.178:5672): user 'cal' authenticated and granted access to vhost 'ssn'

=WARNING REPORT==== 12-Sep-2019::02:16:16 ===
closing AMQP connection <0.27230.0> (99.177.222.248:43706 -> 172.31.12.178:5672, vhost: 'ssn', user: 'cal'):
client unexpectedly closed TCP connection

i'm using an AWS micro instance, Ubuntu 18.04, works with the other tutorials, and the java client is also Ubuntu.

thank you,
Barry

Wesley Peng

unread,
Sep 11, 2019, 10:48:47 PM9/11/19
to rabbitmq-users
Hello,

on 2019/9/12 10:44, Barry von Tobel wrote:
> =WARNING REPORT==== 12-Sep-2019::02:16:16 ===
> closing AMQP connection <0.27230.0> (99.177.222.248:43706 -> 172.31.12.178:5672, vhost: 'ssn', user: 'cal'):
> client unexpectedly closed TCP connection

The error indicates client has closed TCP connection unexpectedly.

We don't know why this happens unless you paste your client code here.

regards.

Barry von Tobel

unread,
Sep 11, 2019, 10:56:53 PM9/11/19
to rabbitmq-users
Hi Wesley,
Its the same code except for some name changes in the java topic tutorials... Here you go...
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.DeliverCallback;

public class ReceiveLogsTopic {

    private static final String EXCHANGE_NAME = "topic_logs";

    public static void main(String[] argv) throws Exception {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("rabbitmq.dyndns.org");
factory.setUsername("cal");
factory.setPassword("cal");
factory.setVirtualHost("ssn");
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();

        channel.exchangeDeclare(EXCHANGE_NAME, "topic");
        String queueName = channel.queueDeclare().getQueue();

        if (argv.length < 1) {
            System.err.println("Usage: ReceiveLogsTopic [binding_key]...");
            System.exit(1);
        }

        for (String bindingKey : argv) {
            channel.queueBind(queueName, EXCHANGE_NAME, bindingKey);
        }

        System.out.println(" [*] Waiting for messages. To exit press CTRL+C");

        DeliverCallback deliverCallback = (consumerTag, delivery) -> {
            String message = new String(delivery.getBody(), "UTF-8");
            System.out.println(" [x] Received '" + delivery.getEnvelope().getRoutingKey() + "':'" + message + "'");
        };
        channel.basicConsume(queueName, true, deliverCallback, consumerTag -> { });

Wesley Peng

unread,
Sep 11, 2019, 11:04:51 PM9/11/19
to rabbitm...@googlegroups.com
Hi

on 2019/9/12 10:56, Barry von Tobel wrote:
>         DeliverCallback deliverCallback = (consumerTag, delivery) -> {
>             String message = new String(delivery.getBody(), "UTF-8");
>             System.out.println(" [x] Received '" +
> delivery.getEnvelope().getRoutingKey() + "':'" + message + "'");
>         };
>         channel.basicConsume(queueName, true, deliverCallback,
> consumerTag -> { });

I didn't saw any error there. :)
But you consume message only, no message producer?

regards.
Message has been deleted

Barry von Tobel

unread,
Sep 11, 2019, 11:36:32 PM9/11/19
to rabbitmq-users
figured it out, a java newbie problem, i needed to have an argument on my receiver,, java ReceiveLogsTopic.java "#"
thank you!

Michael Klishin

unread,
Sep 17, 2019, 2:17:56 PM9/17/19
to rabbitmq-users
Doc section that explains the  message: [1].

Reply all
Reply to author
Forward
0 new messages