Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: Invalid MQTT message type: 11 when trying to publish message #37

Open
Prem326 opened this issue Sep 16, 2015 · 0 comments
Open

Comments

@Prem326
Copy link

Prem326 commented Sep 16, 2015

I am using apollo broker and libmosquitto C library to connect with the broker. Whenever I try to publish any message to the broker, the following error message is recorded in logs in my brokers home directory.
Following is the code snippet that i have been using

void on_publish(struct mosquitto *mosq, void *userdata, int mid)
{
log_print("mqtt",1,"Inside publish callback");
}

int sendData_mqtt(char *address, char *port,char *url,char *data) {
int err;
char *clean_session = "true";
char *retain_flag = "true";
int port1 = atoi(port);
struct mosquitto *mosq;

mosq = mosquitto_new("Mqtt", clean_session, NULL);
mosquitto_publish_callback_set(mosq, on_publish);

mosquitto_username_pw_set(mosq,"admin","password"); 
err=mosquitto_connect(mosq, address, port1,60);

if(err != 0 ){
    log_print("mqtt",1,"connect error= %s\n",mosquitto_strerror(err));
    return -1;
}

mosquitto_publish(mosq, NULL, "Mqtt", strlen(data), data, 1, retain_flag);

mosquitto_loop_forever(mosq, -1, 1);
return 0;   

}

The weird thing is when i use the above program independently, it works fine but currently some other function in some other file is calling senddata_mqtt and in that case it throws the error which I stated above. Please help me know what is going on here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant