rabbitMQ 连接超时 [英] rabbitMQ Connection timed out

查看:618
本文介绍了rabbitMQ 连接超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 vm 上运行了 rabbitMQ 服务器.我正在关注rabbitMQ java教程.它在 vm 本地运行良好,但是当我尝试从主机发送时出现异常

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();

        }
    }

我可以在 192.168.198.100 ping 服务器,但无法访问管理 UI192.168.198.100:15672/

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.

推荐答案

1.

您正在使用 guest guest 作为凭据,并且不允许远程 IP.

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

请阅读:无法访问RabbitMQ网页管理全新安装后的界面那么你必须添加这个:

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.

您是否启用了管理 UI?如果不使用:

Did you enable the management UI? if not use:

rabbitmq-plugins enable rabbitmq_management

3.

检查您的防火墙配置,也许端口 5672 和 15672 已关闭.您可以使用 telnet 来测试端口:

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 '^]'.

和:

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

这篇关于rabbitMQ 连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆