RabbitMQ {握手超时,frame_header}

问题描述 投票:0回答:2

我在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 [信息] <0.20724.9> 连接 <0.20724.9> .xxx.xxx.xxx:57489 -> xxx.xxx.xxx.xxx:5672):用户“用户名”经过身份验证并授予对虚拟主机“/”的访问权限 2018-05-14 10:40:12.856 [info] <0.20724.9> 关闭 AMQP 连接 <0.20724.9> (xxx.xxx.xxx.xxx:57489 -> xxx.xxx.xxx.xxx:5672, vhost: '/', user: '用户名') 2018-05-14 10:40:14.728 [info] <0.20741.9> 接受 AMQP 连接 <0.20741.9> (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:57491 -> xxx.xxx.xxx.xxx:5672): 用户“用户名”已通过身份验证并授予对虚拟主机的访问权限/' 2018-05-14 10:40:14.744 [info] <0.20741.9> 关闭 AMQP 连接 <0.20741.9> (xxx.xxx.xxx.xxx:57491 -> xxx.xxx.xxx.xxx:5672, vhost: '/', user: '用户名') 2018-05-14 10:40:14.884 [info] <0.20756.9> 接受 AMQP 连接 <0.20756.9> (xxx.xxx.xxx.xxx:57493 -> xxx.xxx.xxx.xxx:5672) 2018-05-14 10:40:14.884 [info] <0.20756.9> 连接 <0.20756.9> (xxx.xxx.xxx.xxx:57493 -> xxx.xxx.xxx.xxx:5672): 用户“用户名”已通过身份验证并授予对虚拟主机的访问权限/' 2018-05-14 10:40:14.900 [info] <0.20756.9> 关闭 AMQP 连接 <0.20756.9> (xxx.xxx.xxx.xxx:57493 -> xxx.xxx.xxx.xxx:5672, vhost: '/', user: '用户名') 2018-05-14 10:40:16.756 [info] <0.20771.9> 接受 AMQP 连接 <0.20771.9> (xxx.xxx.xxx.xxx:57495 -> xxx.xxx.xxx.xxx:5672) 2018-05-14 10:40:16.928 [info] <0.20774.9> 接受 AMQP 连接 <0.20774.9> (xxx.xxx.xxx.xxx:57496 -> xxx.xxx.xxx.xxx:5672) 2018-05-14 10:40:36.350 [警告] <0.20771.9> 关闭 AMQP 连接 <0.20771.9> (xxx.xxx.xxx.xxx:57495 -> xxx.xxx.xxx.xxx:5672): {握手超时,帧头} 2018-05-14 10:40:36.350 [警告] <0.20774.9> 关闭 AMQP 连接 <0.20774.9> (xxx.xxx.xxx.xxx:57496 -> xxx.xxx.xxx.xxx:5672): {握手超时,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);
};
c# rabbitmq
2个回答
2
投票

如果将

handshake_timeout
设置为
0
,AMQP 握手永远不会成功,因为它会立即超时。这就是您在日志中看到的内容。


0
投票

可能你的rabbit节点名称错误,你可以启用rabbitmq-pluginsrabbitmq_management,然后访问web修改cluster名称与你的rabbitmq-env.conf NODENAME相同。

© www.soinside.com 2019 - 2024. All rights reserved.