如果一方已经关闭或异常终止连接而另一方却还不知道,我们将这样的 TCP 连接称为半打开(Half-Open)的。任何一端的主机异常都可能导致发生这种情况。只要不打算在半打开连接上传输数据,仍处于连接状态的一方就不会检测另一方已经出现异常。半打开连接的一个常见原因是,当客户主机突然掉电,而不是正常的结束客户应用程序后再关机。当然这里所谓的客户机并不是仅仅表示客户端。
* \param [in] heartbeat the number of seconds between heartbeat frame to * request of the broker. A value of 0 disables heartbeats. * Note rabbitmq-c only has partial support for hearts, as of * v0.4.0 heartbeats are only serviced during amqp_basic_publish(), * and amqp_simple_wait_frame()/amqp_simple_wait_frame_noblock()目前 github 上的 rabbitmq-c 0.4.1 版本在 heartbeat 功能上的支持仅限上述 3 种 API。
[warn] evsignal_init: socketpair: No error drive_machine: [conn_init] --- TCP 3-way handshake start! --> [172.16.81.111:5672][s:53144] drive_machine: [conn_connecting] --- connection timeout 1 time on socket(53144) drive_machine: [conn_connected] --- connected on socket(53144) 53144: conn_state change connected ==> snd_protocol_header --> Send Protocol.Header! 53144: conn_state change snd_protocol_header ==> rcv_connection_start_method [53144] drive_machine: wait for Connection.Start method another 10 seconds!! <-- Recv Connection.Start Method frame! 53144: conn_state change rcv_connection_start_method ==> snd_connection_start_rsp_method --> Send Connection.Start-Ok Method frame! 53144: conn_state change snd_connection_start_rsp_method ==> rcv_connection_tune_method <-- Recv Connection.Tune Method frame! 53144: conn_state change rcv_connection_tune_method ==> snd_connection_tune_rsp_method --> Send Connection.Tune-Ok Method frame! 53144: conn_state change snd_connection_tune_rsp_method ==> snd_connection_open_method --> Send Connection.Open Method frame! 53144: conn_state change snd_connection_open_method ==> rcv_connection_open_rsp_method <-- Recv Connection.Open-Ok Method frame! 53144: conn_state change rcv_connection_open_rsp_method ==> snd_channel_open_method --> Send Channel.Open Method frame! 53144: conn_state change snd_channel_open_method ==> rcv_channel_open_rsp_method [53144] drive_machine: wait for Channel.Open-Ok method another 10 seconds!! <-- Recv Channel.Open-Ok Method frame! 53144: conn_state change rcv_channel_open_rsp_method ==> idle [53144] drive_machine: [conn_idle] --- [CONSUMER]: Queue Declaring! 53144: conn_state change idle ==> snd_queue_declare_method --> Send Queue.Declare Method frame! 53144: conn_state change snd_queue_declare_method ==> rcv_queue_declare_rsp_method [53144] drive_machine: wait for Queue.Declare-Ok method another 10 seconds!! <-- Recv Queue.Declare-Ok Method frame! 53144: conn_state change rcv_queue_declare_rsp_method ==> idle [53144] drive_machine: [conn_idle] --- [CONSUMER]: Queue Binding! 53144: conn_state change idle ==> snd_queue_bind_method --> Send Queue.Bind Method frame! 53144: conn_state change snd_queue_bind_method ==> rcv_queue_bind_rsp_method [53144] drive_machine: wait for Queue.Bind method another 10 seconds!! <-- Recv Queue.Bind Method frame! need to code something! 53144: conn_state change rcv_queue_bind_rsp_method ==> idle [53144] drive_machine: [conn_idle] --- [CONSUMER]: Basic QoS! 53144: conn_state change idle ==> snd_basic_qos_method --> Send Basic.Qos Method frame! 53144: conn_state change snd_basic_qos_method ==> rcv_basic_qos_rsp_method <-- Recv Queue.Qos-Ok Method frame! need to code something! 53144: conn_state change rcv_basic_qos_rsp_method ==> idle [53144] drive_machine: [conn_idle] --- [CONSUMER]: Basic Consuming! 53144: conn_state change idle ==> snd_basic_consume_method --> Send Basic.Consume Method frame! 53144: conn_state change snd_basic_consume_method ==> rcv_basic_consume_rsp_method <-- Recv Basic.Consume-Ok Method frame! need to code something! 53144: conn_state change rcv_basic_consume_rsp_method ==> idle [53144] drive_machine: [conn_idle] --- [CONSUMER]: Start waiting to recv! 53144: conn_state change idle ==> rcv_basic_deliver_method [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! ### Recv AMQP_FRAME_HEARTBEAT frame! ### <-- Recv Heartbeat frame! 53144: conn_state change rcv_basic_deliver_method ==> snd_heartbeat --> Send Heartbeat frame! 53144: conn_state change snd_heartbeat ==> rcv_basic_deliver_method [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! ### Recv AMQP_FRAME_HEARTBEAT frame! ### <-- Recv Heartbeat frame! 53144: conn_state change rcv_basic_deliver_method ==> snd_heartbeat --> Send Heartbeat frame! 53144: conn_state change snd_heartbeat ==> rcv_basic_deliver_method [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! ### Recv AMQP_FRAME_HEARTBEAT frame! ### <-- Recv Heartbeat frame! 53144: conn_state change rcv_basic_deliver_method ==> snd_heartbeat --> Send Heartbeat frame! 53144: conn_state change snd_heartbeat ==> rcv_basic_deliver_method [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: wait for Basic.Deliver method another 10 seconds!! [53144] drive_machine: Recv nothing for 60s! [53144] drive_machine: Maybe network broken or rabbitmq server fucked! Plz retry consuming! 53144: conn_state change rcv_basic_deliver_method ==> close [53144] drive_machine: [conn_close] --- Connection Disconnect! ### CB: Connection Disconnect! Msg : [Connection Disconnect]
[warn] evsignal_init: socketpair: No error drive_machine: [conn_init] --- TCP 3-way handshake start! --> [172.16.81.111:5672][s:12184] drive_machine: [conn_connecting] --- connection timeout 1 time on socket(12184) drive_machine: [conn_connected] --- connected on socket(12184) 12184: conn_state change connected ==> snd_protocol_header --> Send Protocol.Header! 12184: conn_state change snd_protocol_header ==> rcv_connection_start_method <-- Recv Connection.Start Method frame! 12184: conn_state change rcv_connection_start_method ==> snd_connection_start_rsp_method --> Send Connection.Start-Ok Method frame! 12184: conn_state change snd_connection_start_rsp_method ==> rcv_connection_tune_method [12184] drive_machine: wait for Connection.Tune method another 10 seconds!! <-- Recv Connection.Tune Method frame! 12184: conn_state change rcv_connection_tune_method ==> snd_connection_tune_rsp_method --> Send Connection.Tune-Ok Method frame! 12184: conn_state change snd_connection_tune_rsp_method ==> snd_connection_open_method --> Send Connection.Open Method frame! 12184: conn_state change snd_connection_open_method ==> rcv_connection_open_rsp_method [12184] drive_machine: wait for Connection.Open-Ok method another 10 seconds!! <-- Recv Connection.Open-Ok Method frame! 12184: conn_state change rcv_connection_open_rsp_method ==> snd_channel_open_method --> Send Channel.Open Method frame! 12184: conn_state change snd_channel_open_method ==> rcv_channel_open_rsp_method [12184] drive_machine: wait for Channel.Open-Ok method another 10 seconds!! <-- Recv Channel.Open-Ok Method frame! 12184: conn_state change rcv_channel_open_rsp_method ==> snd_channel_confirm_select_method --> Send Confirm.Select Method frame! 12184: conn_state change snd_channel_confirm_select_method ==> rcv_channel_confirm_select_rsp_method <-- Recv Confirm.Select-Ok Method frame! Channel in Confirm Mode! 12184: conn_state change rcv_channel_confirm_select_rsp_method ==> idle [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find msg to send! 12184: conn_state change idle ==> snd_basic_publish_method --> Send Basic.Publish Method frame! 12184: conn_state change snd_basic_publish_method ==> snd_basic_content_header --> Send Content-Header frame! 12184: conn_state change snd_basic_content_header ==> snd_basic_content_body --> Send Content-Body frame! 12184: conn_state change snd_basic_content_body ==> rcv_basic_ack_method <-- Recv Basic.Ack Method frame! ### CB: Publisher Confirm -- [Basic.Ack] Delivery_Tag:[1] multiple:[0] 12184: conn_state change rcv_basic_ack_method ==> idle [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds 12184: conn_state change idle ==> snd_heartbeat --> Send Heartbeat frame! 12184: conn_state change snd_heartbeat ==> idle [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds [12184] drive_machine: [conn_idle] --- [PRODUCER]: Find no msg to send! wait another 1 seconds 12184: conn_state change idle ==> snd_heartbeat [12184] drive_machine: Send Heartbeat failed! status = -9 12184: conn_state change snd_heartbeat ==> close [12184] drive_machine: [conn_close] --- Connection Disconnect! ### CB: Connection Disconnect! Msg : [Connection Disconnect]