First thing you should do when debugging this type of problem is adding a message_dropped handler and printing the failure reason:
void init() {
// ...
app_message_register_inbox_dropped(appmsg_in_dropped);
app_message_open(...);
// ...
}
static void appmsg_in_dropped(AppMessageResult reason, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "In dropped: %i", reason);
}
You will find a list of reason code in the documentation.
The two most common problems are:
APP_MSG_BUFFER_OVERFLOW
: The message is too big (see below)APP_MSG_BUSY
: You are sending messages too fast. You cannot send a new message until the previous one has been acknowledged.
The size of the message is equal to the size of the dictionary. The documentation of dict_calc_buffer_size() explains how to calculate it:
1 byte + 7 bytes for each key + the sum of the sizes of the values
Finally, the values passed to app_message_open() are the buffer sizes in bytes.