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

MQTT disconnects with error 36

We are working over the mqtt sample using TLS, connecting to Mosquitto's test server. Everything is working fine while sending short strings, but now we are trying to send ~10-12kB. For that, we have switched the CONFIG_MQTT_MESSAGE_BUFFER_SIZE parameter to 16384 (also tried with bigger values). However, when sending this, we get automatically disconnected, getting the event MQTT_EVT_DISCONNECT in the callback function. We are using the data_publish() function given in the sample.

The error code is 36, which is the message size, so at the beginning we thought that simply the message was too big and this could not be done. However, the maximum size should admit up to 256MB and, even if the broker had limited it to an smaller value, the message should just be dropped, without the disconnection part. Moreover, we have tested it using the terminal, and we are able to send messages up to +8k characters (that's the limit the Windows cmd supports, will try later with Linux).

The message is sent only once, and we are waiting between tests, so we should not be using too many resources of their network. Are we missing something, or we are just overthinking and it is just that we cannot send so big messages?

Parents
  • Hello!

    The maximum size of an IP packet (that we support) is defined in bsd_limits.h: 4096 bytes (defined in nrf_modem_limits.h in future versions of NCS). If you want to upload data larger than this I recommend chunking the data into several messages.

    I would also recommend that you should determine the MTU size of your network. You can find it with the +GGDCONTRDP AT command (note that you have to subtract any protocol (from the IP layer and up) overhead to find the largest payload that can be sent in one packet).

    Best regards,
    Carl Richard

  • Hello again! 

    This was definitely the problem and we've made a solution where we split up the data in several small packages before sending it, as you said. However, we would like to recreate the image on the receiving end by using lambda (we have switched from mosquitto to AWS). But sending a picture in several packages creates some issues that could have been easily avoided if all the data was sent in one packet instead. Is there any way to increase the packet limit beyond 4096 bytes and makes it possible to send everything in one message?

Reply
  • Hello again! 

    This was definitely the problem and we've made a solution where we split up the data in several small packages before sending it, as you said. However, we would like to recreate the image on the receiving end by using lambda (we have switched from mosquitto to AWS). But sending a picture in several packages creates some issues that could have been easily avoided if all the data was sent in one packet instead. Is there any way to increase the packet limit beyond 4096 bytes and makes it possible to send everything in one message?

Children
No Data
Related