Skip to main content



      Home
Home » Eclipse Projects » Paho » Paho MQTT C Client Issue (MQTTAsync_isConnected keeps waiting for mutex lock on imx6 device)
Paho MQTT C Client Issue [message #1763639] Thu, 18 May 2017 05:28 Go to next message
Eclipse UserFriend
Hi
I am using Paho mqtt C Client application.But in my application execution is getting stuck at MQTTAsync_isConnected api. I am using MQTTAsync_publish.c

Have a look on my code:

if ((rc = MQTTAsync_sendMessage(client, topicName, &pubmsg, &opts)) !=
MQTTASYNC_SUCCESS) {
ERROR("Failed to start sendMessage, return code %d\n", rc);
}

// Check it the client is connected.For application restart case.
if(MQTTAsync_isConnected(client) == true){
// Wait for final response if client is disconnected at the time of
// event.
MQTTAsync_waitForCompletion(client, opts.token, 10000L);
}

Prints:::::::::::::::::::::::::::::::::::::::::
Above lock MQTTAsync_createWithOptions
After unlock out of MQTTAsync_createWithOptions
Inside MQTTAsync_setCallbacks above lock
Inside MQTTAsync_setCallbacks after unlock
Inside MQTTAsync_connect
Inside MQTTAsync_connect above lock checking sendthread status
Inside MQTTAsync_connect beloa unlock checking sendthread status
Inside MQTTAsync_connect above lock checking recvthread status
Inside MQTTAsync_connect beloa unlock checking recvthread status
getting oyt of connect
Debug: Initializing Event DB
Debug: Initialization of Event DB complete
Queue ID: 0


WDM Library : Register with WDM
Debug: Successful connection
Debug: Current HW_VERSION: [1.0.0]
Debug: Current SW_VERSION: [1.0.1]
Debug: MODEL_NAME: [EL76]
Debug: Last Firmware Status: [SUCCESS]
WDM Library : "467.notify-manager-app.20" Sent
Inside MQTTAsync_sendMessage
Inside MQTTAsync_send
Getting out of MQTTAsync_send[0]
Getting out of MQTTAsync_sendMessage [0]
Above mutex lock inside MQTTAsync_isConnected[0]

I just want to check if the client is connected or not with the server in my application but execution is getting stuck inside this api.

Can somebody help me with this?
Re: Paho MQTT C Client Issue [message #1763982 is a reply to message #1763639] Tue, 23 May 2017 11:32 Go to previous messageGo to next message
Eclipse UserFriend
Is your application still within another callback? Only one callback can be active at a time, they are meant to be short lived activities. If a process takes a long time, it should be run asynchronously, not within the callback.
Re: Paho MQTT C Client Issue [message #1764016 is a reply to message #1763982] Wed, 24 May 2017 00:57 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ian ,

Actually the below code execution was taking place inside onConnect callback and got stuck for mutex lock.I changed my logic and it resolved my problem on my device(imx6 board).

But i am not sure why it was running when i tried it on linux.

if ((rc = MQTTAsync_sendMessage(client, topicName, &pubmsg, &opts)) !=
MQTTASYNC_SUCCESS) {
ERROR("Failed to start sendMessage, return code %d\n", rc);
}

// Check it the client is connected.For application restart case.
if(MQTTAsync_isConnected(client) == true){
// Wait for final response if client is disconnected at the time of
// event.
MQTTAsync_waitForCompletion(client, opts.token, 10000L);
}

Thanks
Re: Paho MQTT C Client Issue [message #1764054 is a reply to message #1764016] Wed, 24 May 2017 08:31 Go to previous message
Eclipse UserFriend
You shouldn't call waitForCompletion within a callback. It's the only synchronous call within this API, a late addition which I didn't originally plan for. I'll have to update the doc for that.
Previous Topic:Experiencing constant reconnects with paho client v1.1.1 and broker Active MQ 5.14.3
Next Topic:MQTT messages
Goto Forum:
  


Current Time: Fri Jun 20 04:33:16 EDT 2025

Powered by FUDForum. Page generated in 0.04153 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top