rabbitmq使用报错总结

最近公司重构服务器架构,需要用到rabbitmq,在公司搞了一个下午还是连接不上,后来细看了英文说明,测试连接成功,得出如下报错几点。

我用的安装包:otp_win64_21.3.exe(erlang vm)和rabbitmq-server-3.7.13.exe ,最后测试成功。

连接的代码片段如下

   com.rabbitmq.client.ConnectionFactory factory = new com.rabbitmq.client.ConnectionFactory();
   factory.setHost("localhost");
   factory.setPort(5672);
   factory.setUsername("guest");
   factory.setPassword("guest");

默认安装好rabbitmq就有服务(windows服务 IP:5672),或者中间代理(IP:5672),也有web监控(IP:15672);

默认的端口就是5672,用户guest密码guest,但这个用户名只能在本机访问,如果要网络访问,需要做用户管理;

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

Exception in thread "main" java.net.UnknownHostException: locathost

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

Exception in thread "main" java.net.ConnectException: Connection timed out: connect

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

Exception in thread "main" java.net.ConnectException: Connection refused: connect

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

Exception in thread "main" com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.

猜你喜欢

转载自www.cnblogs.com/holyshengjie/p/10585480.html