rabbitMQ Connection timed out

Abu Muhammad

I have rabbitMQ server running on vm. I am following rabbitMQ java tutorial. It works fine locally on the vm but when trying to send from the host I get an exception

Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:714)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:760)
at Send.main(Send.java:16)

here is the send code i am using:

import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import java.util.concurrent.TimeoutException;
import com.rabbitmq.client.Channel;

public class Send {
    private final static String QUEUE_NAME = "hello";

    public static void main(String[] args) throws java.io.IOException, TimeoutException {

            ConnectionFactory factory = new ConnectionFactory();
            factory.setHost("192.168.198.100");
            factory.setPort(5672);
            Connection connection = factory.newConnection();
            Channel channel = connection.createChannel();

            channel.queueDeclare(QUEUE_NAME, false, false, false, null);
            String message = "Hello World from Windows!";
            channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
            System.out.println(" [x] Sent '" + message + "'");

            channel.close();
            connection.close();

        }
    }

I can ping the server at 192.168.198.100 but I can't access the managment UI at 192.168.198.100:15672/

So could anyone help me figure out what's wrong with this issue? Thanks in advance.

Gabriele Santomaggio

1.

You are using guest guest as credentials, and it is not allowed for remote IP.

Please read this: Can't access RabbitMQ web management interface after fresh install then you have to add this:

factory.setPassword("test");
factory.setUsername("test");

2.

Did you enable the management UI? if not use:

rabbitmq-plugins enable rabbitmq_management

3.

check your firewall configuration maybe the ports 5672 and 15672 are closed. You can use telnet to test the ports:

telnet 192.168.198.100 5672
Trying 192.168.198.100...
Connected to 192.168.198.100.
Escape character is '^]'.

and:

telnet 192.168.198.100 15672
Trying 192.168.198.100...
Connected to 192.168.198.100.
Escape character is '^]'.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related