rabbitmq-c icon indicating copy to clipboard operation
rabbitmq-c copied to clipboard

client was closed by rabbit-server no reason

Open zhulu-mike opened this issue 8 years ago • 4 comments

i used rabbitmq-c client to comunicate with rabbit server。but a error happened,after i make connect to server successfully,after many seconds about 150 seconds beow,the server closed connection。the server ip is 192.168.1.17,my client ip is 172.16.7.22。here is the screenshot whith wireshark。 image who can help me ?

zhulu-mike avatar Jun 13 '17 08:06 zhulu-mike

Check if there is some reason given in the server log (if you have access to that). For example, something like

=ERROR REPORT==== 8-Jun-2017::18:49:27 ===
closing AMQP connection <0.459.0> ([::1]:54802 -> [::1]:5672):
missed heartbeats from client, timeout: 1s

sigiesec avatar Jun 13 '17 08:06 sigiesec

Could you provide some sample code that demonstrates the issue?

alanxz avatar Jun 13 '17 15:06 alanxz

there is no special code, just as same as the example。

   conn = amqp_new_connection();
    
    socket = amqp_tcp_socket_new(conn);
    if (!socket) {
        die("creating TCP socket");
    }
    
    status = amqp_socket_open(socket, hostname, port);
    if (status) {
        die("opening TCP socket");
    }
    
    die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 200, AMQP_SASL_METHOD_PLAIN, MQ_USER, MQ_PSD),
                      "Logging in");
    amqp_channel_open(conn, 1);
    die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
    do sth......
    sendMQ(........)

   int sendMQ(amqp_connection_state_t* conn, const char* exchange, const char* routingkey, const char* messagebody)
{
    amqp_basic_properties_t props;
    props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | AMQP_BASIC_DELIVERY_MODE_FLAG;
    props.content_type = amqp_cstring_bytes("text/plain");
    props.delivery_mode = 2; /* persistent delivery mode */
    return amqp_basic_publish(*conn,
                                    1,
                                    amqp_cstring_bytes(exchange),
                                    amqp_cstring_bytes(routingkey),
                                    0,
                                    0,
                                    &props,
                                    amqp_cstring_bytes(messagebody));
}

zhulu-mike avatar Jun 14 '17 02:06 zhulu-mike

We met the same problem, any update for this issue? Have u fixed it? Thank you very much. @zhulu-mike

chunkchen avatar Mar 29 '18 09:03 chunkchen