I'm Studing Mqtt with mosquitto. and I'm making Qos 2 chat app.
I get a source and Testing these. Qos 0 / 1 Send and Receive are work normally well.
but Qos 2 is not good.
Here is my problem.
1) "Publisher" send Qos 2 string "hello" to "Broker". But "Subscriber" dosen't get it.
2) "Publisher" send Qos 2 string "bye" to "Broker". Then "Subscriber" get "hello" message, when i sent before.
3) "Publisher" send Qos 2 string "test" to "Broker". Then "Subscriber" get "bye" message, when i sent before.
I think, "Publisher" can't receive PUBREC message immediately.
What is the problem?.... I missed something.
Hi. I'm Mqtt Newbie.
I'm Studing Mqtt with mosquitto. and I'm making Qos 2 chat app.
I get a source and Testing these. Qos 0 / 1 Send and Receive are work normally well. but Qos 2 is not good.
Here is my problem.
1) "Publisher" send Qos 2 string "hello" to "Broker". But "Subscriber" dosen't get it. 2) "Publisher" send Qos 2 string "bye" to "Broker". Then "Subscriber" get "hello" message, when i sent before. 3) "Publisher" send Qos 2 string "test" to "Broker". Then "Subscriber" get "bye" message, when i sent before.
I think, "Publisher" can't receive PUBREC message immediately. What is the problem?.... I missed something.
Here is my Test Code.
`#include
include
include "mosquitto.h"
define sleep(x) Sleep((x)*1000)
define strdup _strdup
define DEFAULT_MQTT_HOST "127.0.0.1"
define DEFAULT_MQTT_PORT 1883
define DEFAULT_MQTT_KEEPALIVE 60
define DEFAULT_MQTT_TOPIC "EXAMPLE_TOPIC"
define BUF_LENGTH 65536
using namespace std;
void connect_callback(struct mosquitto mosq, void obj, int result) { printf("connect callback, rc=%d\n", result); }
void message_callback(struct mosquitto mosq, void obj, const struct mosquitto_message msg) { printf("message '%.s' for topic '%s'\n", msg->payloadlen, (char*)msg->payload, msg->topic); }
int main(int argc, char* argv) { int rc; char mqtt_host = strdup(DEFAULT_MQTT_HOST); char* mqtt_topic = strdup(DEFAULT_MQTT_TOPIC); int mqtt_port = DEFAULT_MQTT_PORT; int mqtt_keepalive = DEFAULT_MQTT_KEEPALIVE;
}`