Hi
Iam using Paho Mqtt C Client.I have subscribed on a particular topic like
mqtt/TestTopic/# with QoS 1. Now when i am publishing using an mqttfx application on a topic like
mqtt/TestTopic/Name the callback function in my application is getting called infinitly.
Providing below some details regarding my code.
Default connection initializer value.#define MQTTAsync_connectOptions_initi
alizer { {'M', 'Q', 'T', 'C'}, 4, 60, 1, 10, NULL, NULL, NULL, 30, 0,\
NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 1, 60}
MQTTAsync_setCallbacks(client, NULL, connlost, messageArrivedCb, NULL);
conn_opts.keepAliveInterval = 5;
conn_opts.cleansession = 1;
conn_opts.automaticReconnect = 1;
conn_opts._onSuccess_ = onConnect;
conn_opts._onFailure_ = onConnectFailure;
conn_opts.context = client;
int messageArrivedCb(void* context, char* topicName, int topicLen,
MQTTAsync_message* m)
{
int i;
char* payloadptr;
DEBUG("Message Arrived for Topic[%s]\n",topicName);
payloadptr = m->payload;
for(i=0; i<m->payloadlen; i++)
{
putchar(*payloadptr++);
}
putchar('\n');
// DEBUG("Payload[%s]\n",(char*)m->payload);
MQTTAsync_freeMessage(&m);
MQTTAsync_free(topicName);
return SUCCESS;
}
The
issue we are facing is that the Call back for message received on
subscribed topic is getting called multiple times even though a message
is published only once.
I am also getting below prints.
20170712 122804.108 4 ser01 <- PUBLISH msgid: 1 qos: 1 retained: 0 payload: hi buddy
20170712 122804.108 4 ser01 -> PUBACK msgid: 1 (0)
Debug: Message Arrived for Topic[mqtt/testTopic/LCD]
hi buddy
Debug: Message Arrived for Topic[� ]
20170712 122804.108 Failed to remove heap item at file src/MQTTAsync.c line 1617
20170712 122804.108 Failed to remove heap item at file src/MQTTAsync.c line 1618
20170712 122804.108 Failed to remove heap item at file src/MQTTAsync.c line 1627
20170712 122808.985 4 ser01 <- PUBLISH msgid: 2 qos: 1 retained: 0 payload: hi buddy
20170712 122808.985 4 ser01 -> PUBACK msgid: 2 (0)
Debug: Message Arrived for Topic[� ]
hi buddy
20170712 122808.985 Failed to remove heap item at file src/MQTTAsync.c line 1627
20170712 122817.215 4 ser01 -> PINGREQ (0)
20170712 122818.094 4 ser01 <- PINGRESP
Debug: Message Arrived for Topic[� ]
Can anybody tell how to avoid this?