我在rabbitMQ日志中得到以下内容
MQ日志2018-05-14 10:40:12.841 [info]<0.20724.9>接受AMQP连接<0.20724.9>(xxx.xxx.xxx.xxx:57489-> //xxx.xxx.xxx.xxx:5672)2018-05-14 10:40:12.856 [info]<0.20724.9>连接<0.20724.9>. xxx.xxx.xxx.xxx.xxx.xxx:57489-> 5672):用户'XNUMX'已验证并授权访问vhost '/' 2018-05-14 10:40:12.856 [info]<0.20724.9>关闭AMQP连接<0.20724.9>(xxx.xxx.xxx.xxx.xxx:57489-> xxx.xxx.xxx.xxx:5672,vhost:'/',user:'Username')2018-05-14 10:40:14.728 [info]<0.20741.9>接受AMQP连接<0.20741.9>(xxx.xxx.xxx.xxx.xxx:57491-> xxx.xxx.xxx.xxx:5672)2018-05-14 10:40:14.728 [info]<0.20741.9>连接<0.20741.9>(xxx.xxx.xxx.xxx.xxx:57491-> xxx.xxx.xxx.xxx:5672):用户'XNUMX'已验证并授权访问vhost '/' 2018-05-14 10:40:14.744 [info]<0.20741.9>关闭AMQP连接<0.20741.9>(xxx.xxx.xxx.xxx.xxx:57491-> xxx.xxx.xxx.xxx:5672,vhost:'/',user:'Username')2018-05-14 10:40:14.884 [info]<0.20756.9>接受AMQP连接<0.20756.9>(xxx.xxx.xxx.xxx.xxx.xxx:57493-> 5672)2018-05-14 10:40:14.884 [info]<0.20756.9>连接<0.20756.9>(xxx.xxx.xxx.xxx.xxx.xxx:57493-> 5672):用户'XNUMX'已验证并授权访问vhost '/' 2018-05-14 10:40:14.900 [info]<0.20756.9>关闭AMQP连接<0.20756.9>(xxx.xxx.xxx.xxx.xxx:57493-> xxx.xxx.xxx.xxx:5672,vhost:“/”,用户:“用户名”)2018-05-14 10:四十:16.756 [info]<0.20771.9>接受AMQP连接<0.20771.9>(xxx.xxx.xxx.xxx:57495-> xxx.xxx.xxx.xxx:5672)2018-05-14 10:四十:16.928 [info]<0.20774.9>接受AMQP连接<0.20774.9>(xxx.xxx.xxx.xxx:57496-> xxx.xxx.xxx.xxx:5672)2018-05-14 10:四十:36.350 [警告]正在<0.20771.9>关闭AMQP连接<0.20771.9>(xxx.xxx.xxx.xxx:57495-> xxx.xxx.xxx.xxx:5672):{handshake_timeout,frame_header} 2018-05-14 10:40:36.350 [warning]正在<0.20774.9>关闭AMQP连接<0.20774.9>(xxx.xxx.xxx.xxx:57496-> xxx.xxx.xxx.xxx:5672):{handshake_timeout,frame_header}
我在我的配置中有以下内容
[
{handshake_timeout, 0},
].
以及值为0的环境变量heartbeat
我的代码如下
public static void Recieve()
{
var User = figurationManager.AppSettings["RabbitMQUserName"];
var Pass = ConfigurationManager.AppSettings["RabbitMQPass"];
var Server = ConfigurationManager.AppSettings["Server"];
var Port = Int32.Parse(ConfigurationManager.AppSettings["Port"]);
ConnectionFactory factory = new ConnectionFactory();
factory.UserName = User;
factory.Password = Pass;
factory.VirtualHost = "/";
factory.HostName = Server;
factory.Port = Port;
IConnection conn = factory.CreateConnection();
IModel channel = conn.CreateModel();
channel.BasicQos(0, 1, false);
channel.QueueDeclare(queue: "QueName",
durable: true,
exclusive: false,
autoDelete: false,
arguments: null);
//channel.ExchangeDeclare("amq.direct", ExchangeType.Direct);
channel.QueueBind("QueName", "amq.direct", "", null);
bool sent = true;
var consumer = new EventingBasicConsumer(channel);
consumer.Received += (ch, ea) =>
{
var body = ea.Body;
var message = Encoding.UTF8.GetString(body);
sent = Send(message);
if (sent)
{
channel.BasicAck(ea.DeliveryTag, true);
}
else
{
channel.BasicReject(ea.DeliveryTag, true);
}
};
String consumerTag = channel.BasicConsume("QueName", false`enter code here`, consumer);
};
2条答案
按热度按时间mutmk8jj1#
如果将
handshake_timeout
设置为0
,AMQP握手将永远不会成功,因为它会立即超时。这就是你在日志中看到的。1dkrff032#
也许你的rabbit节点名有误,你可以启用rabbitmq插件rabbitmq_management,然后访问web修改clouster名称,使其与你的rabbitmq-env.conf NODENAME相同。