This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

MQTT service cannot work when RAI is set

When we develop out product, we found it cannot connect to our server. After our check step by step, we found if we comment the code about RAI setting, MQTT service can be used. When we set "AT%XRAI=4", MQTT will return an error. The error code is -116. Is there any conflict between them?

Parents Reply Children
  • It still doesn't answer when you are setting it.

    Setting it to 4 will always be wrong when you are using TCP. You always expect an ACK to any transmission you send.

    But, even if you set it to 3, you probably are not getting the effect you want. When RAI is set, the flag is sent with any packets sent from the modem until the flag is unset. This means that if you still haven't sent the "last" packet (e.g. because of bad network conditions, or you are sending multiple packets), you will get released early, then have to re-establish the RRC connection so that you can send the next packet (and if you have more than 1 more packet to send, this will continue until all packets are sent).

    If you set the RAI flag before you call mqtt_connect, you will encounter just this scenario. In mqtt_connect you might have a DNS lookup, followed by a TCP SYN, TCP SYN ACK from the server, TCP ACK from you, possible TLS handshake which consists of multiple packets, the MQTT connection request, and the server's acknowledgement. All of these will have the RAI flag set, which means you will have a lot of RRC connection releases and setups.

    All the extra signaling required for managing the RRC connections migh mess up the timing of the TCP traffic, cause missed packets, or just increase the power consumption.

    My recommandadtion is to only use RAI when you are using fairly simple UDP based protocols.

  • Hi,

    Thank you for your answer. I will consider to use default setting of RAI.

Related