- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not able to connect with MQTT server for subscribing messages,after 10 second its disconnected,i am using paho mqtt embedded C libarary.Not getting ConnAck response from java Mqtt server running on windows platform.
Application code:
MQTT_func()
{
MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
int rc = 0;
// int mysock = 0;
unsigned char buf[200];
int buflen = sizeof(buf);
int msgid = 1;
MQTTString topicString = MQTTString_initializer;
int req_qos = 0;
char* payload = "mypayload";
int payloadlen = strlen(payload);
int len = 0;
//Socket creation
WPRINT_APP_INFO(("mysock_kuldeep = %d \n\r", mysock));
mysock = transport_open();
if(mysock < 0)
{
transport_close(mysock);
return mysock;
}
data.clientID.cstring = "hello";//"SampleJavaV3_subscribe";
data.keepAliveInterval = 20;
data.cleansession = 1;
data.MQTTVersion = 4;
len = MQTTSerialize_connect((unsigned char *)buf, buflen, &data);
WPRINT_APP_INFO(("lenth hello: %d\n",len));
transport_sendPacketBuffer(mysock, buf, len);
unsigned char sessionPresent, connack_rc,tempbuf[50];
if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) != 1 || connack_rc != 0)
{
WPRINT_APP_INFO(( "Unable to connect, return code %d\n", connack_rc));
// WPRINT_APP_INFO(("%s",tempbuf));
// transport_close(mysock);
//return 0;
}
else
{
WPRINT_APP_INFO(("Didnt reveive CONNACK \n"));
// transport_close(mysock);
// return 0;
}
topicString.cstring = "Smart";
len = MQTTSerialize_subscribe(buf, buflen, 0, msgid, 1, &topicString, &req_qos);
WPRINT_APP_INFO(("mysock = %d \n\r", mysock));
transport_sendPacketBuffer(mysock, buf, len);
if (MQTTPacket_read(buf, buflen, transport_getdata) == SUBACK) /* wait for suback */
{
WPRINT_APP_INFO(("After MQTTPacket_read \n"));
unsigned short submsgid;
int subcount;
int granted_qos;
MQTTDeserialize_suback(&submsgid, 1, &subcount, &granted_qos, buf, buflen);
if (granted_qos != 0)
{
WPRINT_APP_INFO(("granted qos != 0 \n"));
//transport_close(mysock);
//return 0;
}
}
else
{
WPRINT_APP_INFO(("Didnt reveive SUBACK \n"));
// transport_close(mysock);
//return 0;
}
}
logs:
Successfully joined : SMART_IOT
Obtaining IPv4 address via DHCP
Setting IPv6 link-local address
IPv4 network ready IP: 10.100.10.106
Getting NTP time...
failed, trying again...
failed, trying again...
failed, trying again...
Give up getting NTP time
BT SmartBridge application is running. Please go to the webpage
Connection with TCP server established successfully
wait for connack
Unable to connect, return code 115
mysock = 0
Before MQTTPacket_read
Didnt reveive SUBACK
- Tags:
- wiced eval board
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Kuldeep,
You may want to try the latest sdk that has support for AWS.
It may suffice what you are trying to solve.
The link can be found here:
WICED SDK supporting Amazon Web Services 3.4.0-AWS
Cheers,
AB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just wondered if you are now able to run successfully the paho mqtt embedded C library from your
"broadcom" board?
I have some problem with synchronous paho mqtt C clients(posix) on Rpi3. Connecting 2 client to a Mosquitto Broker. One connection is working fine, when the second comes on, it disconnect the first one? Does WICED/Broadcom boards like BCM4343w support/work well, running two instances of Paho MQTT C Clients?