4 Replies Latest reply on Jul 11, 2018 4:10 AM by jecoc_2594171

    AMQP V1.0 : Heartbeat



      I would like to know if the "principle" of the heartbeat is functional with AMQP V1.0 protocol (is it with the V0.9 version of AMQP) ?


      I see a lot of parameters like : WICED_AMQP_FRAME_TYPE_HEARTBEAT

      but nothing created around to use it in V1.0 around.


      so is that used and functionnal with AMQP V9.0 protocol ?

        • 1. Re: AMQP V1.0 : Heartbeat

          WICED AMQPv0.9 has heartbeat feature but there is no sample application to demonstrate the feature.
          The AMQPv1.0 spec has no information about heartbeat feature. User have to send empty packets to keep the connection alive.

          1 of 1 people found this helpful
          • 2. Re: AMQP V1.0 : Heartbeat

            I tried to set up a heartbeat or a regular ping to keep the connection active according to the request of the OASIS documentation
            (OASIS Advanced Message Queuing Protocol (AMQP) Version 1.0)

            « The use of idle timeouts is in addition to any network protocol level control. Implementations
            SHOULD make use of TCP keep-alive wherever possible in order to be good citizens. If a peer
            needs to satisfy the need to send traffic to prevent idle timeout, and has nothing to send, it
            MAY send an empty frame, i.e., a frame consisting solely of a frame header, with no frame
            body. Implementations MUST be prepared to handle empty frames arriving on any valid
            channel, though implementations SHOULD use channel 0 when sending empty frames, and
            MUST use channel 0 if a maximum channel number has not yet been negotiated (i.e., before
            an open frame has been received). Apart from this use, empty frames have no meaning. »


            Finally to keep the connection alive, we tested the following things in vain :
            1. Send a header frame (every 30sec) with amqp_manager() function and the
            parameter :WICED_AMQP_EVENT_SASL_HDR_SENT.
            2. Send a « flow » frame (every 30sec) with fwiced_amqp_update_link_credit()
            function, device avoid idle time out after 4 min but could be disable after 1-2 hours.
            3. Send a keep alive according to the test snip/keep_alive and a ping with wiced_ping()
            function on amqp socket.


            Main problem is if I use AMQP libraries to send empty packets to keep the connection alive,it is not free !

            • 3. Re: AMQP V1.0 : Heartbeat


              The spec says that we need to send an empty packet to maintain the AMQP connection and as per your comments, I believe you are sending one. I just need few more details about the packet:

              1. Why is a SASL_HDR sent? It should be a transfer packet with data length=0.

              2. What is the maximum time the device for which the client is not sending data to the server? Azure have an idle timeout of 10 minutes and if no transfer takes place within this time, the connection will be closed.

              3. What is the channel number on which you are sending the packet? Empty packets should be on channel 0

              4. What happens when you try to send the data after the connection is lost? Do you receive any CONNECTION_ERROR event? If the connection (i.e.,the TCP connection is lost) the callback function "amqp_network_disconnect_callback" should be called. The queued error is then taken care in "amqp_network_queue_thread".

              Can you check if these functions are called when link is broken?

              1 of 1 people found this helpful
              • 4. Re: AMQP V1.0 : Heartbeat



                1 - I already try to send an empty packet with the original way (function amqp_send to send an empty frame) but it was not free on amqp side.

                2 - Azure iot has an idle timeout around 4min.

                3 - I use channel 0 ( I think all frame use this way with wiced functions on Azure).

                4 - When the connection is lost I receive connection event on amqp manager function.