** Description changed:
I am using apollo broker, and mosquitto v 3.1 C client library to
interact with the broker. I am using a basic program to test the client
and the broker. While the program works nicely with qos 1, it does not
work with qos 0 and I cannot find the reason why it is not working with
qos 0. I am using a ubuntu 14.04LTS. Ill add the code that I am using
below. Please help me
#include<stdio.h>
#include<stdlib.h>
#include<mosquitto.h>
void on_publish(struct mosquitto *mosq, void *userdata, int mid)
{
- printf("Inside publish callback");
- mosquitto_disconnect(mosq);
+ printf("Inside publish callback");
+ mosquitto_disconnect(mosq);
}
int main(int argc, char *argv[])
{
- struct mosquitto *mosq;
- int err;
- int err1;
-
+ struct mosquitto *mosq;
+ int err;
+ int err1;
- mosq = mosquitto_new("unknown", true, NULL);
- mosquitto_publish_callback_set(mosq, on_publish);
+ mosq = mosquitto_new("unknown", true, NULL);
+ mosquitto_publish_callback_set(mosq, on_publish);
- mosquitto_username_pw_set(mosq,"admin","password");
- err=mosquitto_connect(mosq, "localhost", 61613,60);
+ mosquitto_username_pw_set(mosq,"admin","password");
+ err=mosquitto_connect(mosq, "localhost", 61613,60);
- if(err != 0 ){
- printf("connect error= %s\n",mosquitto_strerror(err));
- printf("error : %d\n",err1);
- exit(0);
- }
+ if(err != 0 ){
+ printf("connect error= %s\n",mosquitto_strerror(err));
+ printf("error : %d\n",err1);
+ exit(0);
+ }
- err1 = mosquitto_publish(mosq, NULL, "subject", 11, "Works", 1, true);
-
- printf("Publish error = %s\n",mosquitto_strerror(err1));
-
- mosquitto_loop_forever(mosq, -1, 1);
- return 0;
+ err1 = mosquitto_publish(mosq, NULL, "subject", 11, "Works", 0,
+ true);
+
+ printf("Publish error = %s\n",mosquitto_strerror(err1));
+
+ mosquitto_loop_forever(mosq, -1, 1);
+ return 0;
}
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1495379
Title:
mosquitto C program not working with qos 0
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mosquitto/+bug/1495379/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs