Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iDon't treat an unexpected PUBREL as fatal.
Issue #1629. Thanks to radcrabs.
- Loading branch information
Showing
6 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include <stdbool.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <mosquitto.h> | ||
|
||
static int run = -1; | ||
|
||
void on_connect(struct mosquitto *mosq, void *obj, int rc) | ||
{ | ||
if(rc){ | ||
exit(1); | ||
} | ||
} | ||
|
||
void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_message *msg) | ||
{ | ||
if(msg->mid != 13423){ | ||
printf("Invalid mid (%d)\n", msg->mid); | ||
exit(1); | ||
} | ||
if(msg->qos != 2){ | ||
printf("Invalid qos (%d)\n", msg->qos); | ||
exit(1); | ||
} | ||
if(strcmp(msg->topic, "pub/qos2/receive")){ | ||
printf("Invalid topic (%s)\n", msg->topic); | ||
exit(1); | ||
} | ||
if(strcmp(msg->payload, "message")){ | ||
printf("Invalid payload (%s)\n", (char *)msg->payload); | ||
exit(1); | ||
} | ||
if(msg->payloadlen != 7){ | ||
printf("Invalid payloadlen (%d)\n", msg->payloadlen); | ||
exit(1); | ||
} | ||
if(msg->retain != false){ | ||
printf("Invalid retain (%d)\n", msg->retain); | ||
exit(1); | ||
} | ||
|
||
run = 0; | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
int rc; | ||
struct mosquitto *mosq; | ||
|
||
int port = atoi(argv[1]); | ||
|
||
mosquitto_lib_init(); | ||
|
||
mosq = mosquitto_new("publish-qos2-test", true, &run); | ||
mosquitto_connect_callback_set(mosq, on_connect); | ||
mosquitto_message_callback_set(mosq, on_message); | ||
mosquitto_message_retry_set(mosq, 5); | ||
|
||
rc = mosquitto_connect(mosq, "localhost", port, 60); | ||
|
||
while(run == -1){ | ||
rc = mosquitto_loop(mosq, 300, 1); | ||
if(rc){ | ||
printf("%d:%s\n", rc, mosquitto_strerror(rc)); | ||
exit(1); | ||
} | ||
} | ||
|
||
mosquitto_lib_cleanup(); | ||
return run; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters