Rabbitmq安装及连接错误问题

Rabbitmq连接测试以及本地报错问题

          • 1、如果写错了host (如:factory.setHost("locathost"); )报错
            • 2 、如果写错了HOST的IP(如:factory.setHost("192.168.1.10"); )无此地址, 报错:
            • 3、如果写错端口PORT(如:factory.setPort(5678);) 报错:
            • 4、如果写错用户名或者密码,报错:
          • 5、解决方法

本人在学习spingcloud的时候,学习到消息总线时遇到的问题,
首先需要安装下载Rabbitmq
借鉴这位博主的文章: https://blog.csdn.net/newbie_907486852/article/details/79788471
添加用户修改密码: http://www.cnblogs.com/fjzhang/p/8403979.html

我的配置:
Rabbitmq安装及连接错误问题_第1张图片
host:也可以写成127.0.0.1本机端口。远程请写成自己本地的端口
就是因为我自己新添加的用户没有修改权限就出现了第三种错误:

找了好多资料,看到了这个:
https://blog.csdn.net/java_xiaobin/article/details/46964805

1、如果写错了host (如:factory.setHost(“locathost”); )报错

Exception in thread “main” java.net.UnknownHostException: locathost
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:588)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:612)
at com.aaa.test.Send.main(Send.java:19)

2 、如果写错了HOST的IP(如:factory.setHost(“192.168.1.10”); )无此地址, 报错:

Exception in thread “main” java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:588)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:612)

3、如果写错端口PORT(如:factory.setPort(5678);) 报错:

Exception in thread “main” java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:588)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:612)
at com.aaa.test.Send.main(Send.java:19)

4、如果写错用户名或者密码,报错:

Exception in thread “main” com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:338)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:590)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:612)
at com.aaa.test.Send.main(Send.java:19)

5、解决方法

1.首先点击用户
图片: Rabbitmq安装及连接错误问题_第2张图片

2.点击自己注册的用户名
图片:
Rabbitmq安装及连接错误问题_第3张图片

3.点击Set permission进行授权
图片:
Rabbitmq安装及连接错误问题_第4张图片

嗯哼,完成!

你可能感兴趣的:(springcloud)