rabbitmq坑点与异常处理

from:http://www.cnblogs.com/gossip/p/4573056.html

一、None of the specified endpoints were reachable

这个异常在创建连接时抛出(CreateConnection()),原因一般是ConnectionFactory参数设置不对,比如HostName、UserName、Password

标准设置:

var factory = new ConnectionFactory();

factory.UserName = QueueSetttiong.UserName;   //用户名

factory.Password = QueueSetttiong.Password;      //密码

factory.HostName = QueueSetttiong.HostName;  //Rabbitmq服务IP,不包含端口

factory.Port = AmqpTcpEndpoint.UseDefaultPort;

factory.VirtualHost = QueueSetttiong.VirtualHost;  //默认为"/"

factory.Protocol = Protocols.DefaultProtocol;

部署生产后,factory配置都ok,但是还是抛异常None of the specified endpoints were reachable,最后发现原因是生产机器防火墙未打开RabbitMQ的端口,RabbitMQ的默认端口是:5672

另外一个可能的原因:未设置VirtualHost的权限

设置方法:RabbitmqWeb管理网站-->Admin

未设置权限时:

设置权限:(点击admin进入设置页面)

二、异常:unable to connect to node rabbit@10: nodedown

网上说要修改主机名,找半天不知道怎么修改,重新安装Rabbitmq服务端即可,有时候需要重启

三、异常:Message:Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=320, text="CONNECTION_FORCED - broker forced connection closure with reason 'shutdown'", classId=0, methodId=0, cause= StackTrace

原因:队列服务端重启后,队列发布端断开了接口,无法再次发送消息

解决:发送端设置断开连接后自动启动属性,默认为断开后每隔五秒钟重试连接

var factory = new ConnectionFactory();

factory.AutomaticRecoveryEnabled = true;   //设置端口后自动恢复连接属性即可

四、Rabbitmq实际数据文件、日志文件、配置文件路径

地址栏输入:%APPDATA%\RabbitMQ\

C:\Users\Administrator\AppData\Roaming\RabbitMQ

信息来源:C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.5.1\etc 中的README.txt

posted @   94cool  阅读(9155)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示