Comments (5)
Hi @daanpape, thanks for writing.
That is strange, especially since your messages are QOS 0. Since they're QoS 0, all your publish messages should go to the MQTT_QUEUED_COMPLETE
state as soon as __mqtt_send
(called in mqtt_sync
) is called (that happens here).
Do you think it's possible there's a message at the head of your message queue that remains in some unackknowledged state (e.g. your connection request)? When mqtt_mq_clean
is called, it can only free-up space from the start of the buffer to the first message that is not MQTT_QUEUED_COMPLETE
. If, for example, you never receive the CONNACK packet from the broker, the CONNECT message at the head of your queue would prevent the entire message queue from ever being cleaned (here is where the received CONNACK puts your initial CONNECT message into the completed state). To me it seems like there must be something at the start of your queue that goes unacknowledged. Do you think this is possible?
To troubleshoot your issue, you could try inspecting your message queue (here is the documentation for working the with the internal message queue...it's pretty straightforward to inspect it). You could essentially loop through each message in the queue (you can get the messages with mqtt_mq_get
) and inspect its state (e.g. MQTT_QUEUED_AWAITING
) and control type (e.g. MQTT_CONTROL_PUBLISH
).
Other questions:
- Are you using the default Unix PAL?
- Are you working on any unusual architectures or platforms?
- What broker are you using?
from mqtt-c.
Hello @LiamBindle,
Thank you for the fast reply. I'm first going to answer your other questions:
- Yes I'm using an unmodified PAL file.
- I'm running the software on OpenWRT on a MIPS processor
- I'm using a broker i wrote myself but which is tested with multiple MQTT clients
To answer your first question: I learned that everything is possible :), ok now to be more serious. I highly doubt that there would be a pending CONACK. I have monitored traffic between my broker and the mqttfx client application with the following result:
It seems to me that the broker responds correctly with a CONACK. I'm now going to look to the docs and try to inspect the transmit queue. I will update with more info soon.
Kind regards,
Daan
from mqtt-c.
Hello @LiamBindle,
I managed to see the problem by inspecting the message queue:
MQTT_PAL_MUTEX_LOCK(&client.mutex);
for(size_t i = 0; i < mqtt_mq_length(&(client.mq)); ++i) {
struct mqtt_queued_message *msg = mqtt_mq_get(&(client.mq), i);
log_debug("MQTT", "Message %d has state %s and control type %s\n", i, _mqtt_state_to_str(msg->state), _mqtt_control_type_to_str(msg->control_type));
}
MQTT_PAL_MUTEX_UNLOCK(&client.mutex);
And I now get the output:
[2019-12-03 19:24:14][DEBUG][MQTT] Message 0 has state MQTT_QUEUED_AWAITING_ACK and control type MQTT_CONTROL_SUBSCRIBE
[2019-12-03 19:24:14][DEBUG][MQTT] Message 1 has state MQTT_QUEUED_AWAITING_ACK and control type MQTT_CONTROL_SUBSCRIBE
[2019-12-03 19:24:14][DEBUG][MQTT] Message 2 has state MQTT_QUEUED_AWAITING_ACK and control type MQTT_CONTROL_SUBSCRIBE
[2019-12-03 19:24:14][DEBUG][MQTT] Message 3 has state MQTT_QUEUED_COMPLETE and control type MQTT_CONTROL_PUBLISH
As you expected something keeps hanging at the start of the queue. I'm going to fix this in my broker and report back here. But I think you can set this issue as handled.
I'm sorry for the disturbance and thank you very much for helping me out and pointing me in the right direction.
from mqtt-c.
I have now updated my broker implementation and this completely fixed the problem. Thanks again @LiamBindle
from mqtt-c.
@daanpape Oh great, I'm glad you got your issue solved 😄
Let me know if you run into any more problems!
from mqtt-c.
Related Issues (20)
- Would reconnect_publisher be a thing? HOT 3
- Adding contex to callbacks HOT 1
- Insufficient validation of PUBLISH message HOT 2
- Possible undefined behaviour/bad memory access after reconnect HOT 2
- MQTT_ERROR_SEND_BUFFER_IS_FULL due to transient MQTT_ERROR_SOCKET_ERROR
- FPU-Trap when calculating client->typical_response_time
- mqtt_publish return value causes mqtt_error_str when not connected
- mqtt_publish seems to only send QoS 0 HOT 1
- Possible bug in MQTT_CLIENT_TRY_PACK macro
- MQTT-C Security Issue Report (mqtt_unpack_publish_response) HOT 2
- swap use of double variables to float HOT 1
- How to check the client has received a Connack from the Broker after connect() HOT 7
- how to check network connection state in inspector callback
- Signed integer overflow in `mqtt_error_str()` HOT 2
- We cannot pass the context of the program to mqtt publish_callback HOT 2
- Mingw compile error
- Memory alignment in Keil ARM Compiler (thumb instruction set)
- mqtt_connect does not generate a client.error if wrong username and/or password is provided
- Unable to connect openssl_publisher example to HiveMQ HOT 2
- Windows MSYS2 MINGW64: Examples fail with "MQTT_ERROR_SOCKET_ERROR" or "Failed to open socket: : No error"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqtt-c.