Comments (6)
Hi @Wenn-x,
Message acknowledgements are only valid for QoS 1 + 2 messages. From the code you posted, you are only handling QoS 0 messages. Could this be the issue?
The QoS docs if you need them:
https://hivemq.github.io/hivemq-mqtt-client/docs/mqtt-operations/publish/#quality-of-service-qos
from hivemq-mqtt-client.
Hi @pglombardo, thanks for your reply. Actually, I tried Qos 1 or 2 once, but got an error in the log which is considered maybe a bug of emqx in #491. So I ignored it. How can I solve this?
QoS 2 PUBLISH (MqttStatefulPublish{stateless=MqttPublish{topic=test, payload=22byte, qos=EXACTLY_ONCE, retain=false}, packetIdentifier=1, dup=false, topicAlias=0, subscriptionIdentifiers=[1]}) must not be resent (MqttStatefulPublish{stateless=MqttPublish{topic=test, payload=22byte, qos=EXACTLY_ONCE, retain=false}, packetIdentifier=1, dup=true, topicAlias=0, subscriptionIdentifiers=[1]}) during the same connection
from hivemq-mqtt-client.
Ugh I see - I wasn't aware of that issue in EMQX. They are referring to the first paragraph in this section of the specification which makes sense.
Publishes are not allowed to be resent on the same connection until reconnect with cleanStart = false.
I think the only way to resolve this is to contact EMQX or switch to another broker. Beyond this specific instance, being non-compliant with the protocol spec risks many secondary and longer term issues for users.
If I can help with anything else, please let me know.
from hivemq-mqtt-client.
Hi @pglombardo, maybe I didn't express it clearly. The error message was from the source code: com.hivemq.client.internal.mqtt.handler.publish.incoming.MqttIncomingQosHandler#readPublishQos2
. I think this has nothing to do with emqx. What I don't understand is whether this constraint conflicts with receiving duplicate messages without manual confirmation. Is there anything else I need to do?
from hivemq-mqtt-client.
Hi @Wenn-x - that's correct. This Java client correctly throws that error when the protocol is violated by the EMQ broker.
I'll try to explain more thoroughly:
Messages that are not acknowledged, are not allowed to be resent on the same connection. Those unacknowledged messages can only be sent on reconnect. When the broker you are using resends the messages on the same connection, this client correctly throws this error because it is a protocol violation.
It seems like a small distinction but these are the rules of the MQTT protocol. Strict adherence to the protocol specification guarantees predictable behavior & reliability when deploying to millions of devices and processing millions of messages per day (or more).
A couple notes:
- Mosquitto used to incorrectly resend unacknowledged publishes as well but this was fixed in 2018.
- The HiveMQ broker also follows the protocol spec and does not resend unacknowledged messages until reconnect.
My advice would be to try another broker and see the difference in behavior. Then with that knowledge, you can make the right decision on which path to pursue.
I hope I explained this well enough. Please let me know if not.
from hivemq-mqtt-client.
Hi @pglombardo, thanks a lot for your explanation. My requirement scenario is that when some messages cannot be processed correctly in program, I hope to receive them again. I tried disconnect and reconnect the MQTT client with cleanStart = false, but still got nothing. Is the correct way to use manual acknowledgement or I should find other ways?
from hivemq-mqtt-client.
Related Issues (20)
- What is use of acknowledge function in Mqtt5Publish class ? HOT 2
- Add HiveMQ MQTT client as alternative to Paho in Spring Integration HOT 1
- Retained messages aren't pushed to the listener HOT 1
- Exception while decoding PUBLISH: topic alias must not exceed topic alias maximum HOT 3
- Messages lost when using both MQTTv3 and MQTTv5 clients in async mode HOT 3
- MqttAsyncClient sometimes blocking indefinitely on publish HOT 1
- Add documentation on manual message acknowledgement HOT 1
- Make Reconnect Failure Behavior Configurable
- Improve PINGREQ <--> PINGRESP reliability during network change
- Clarify & Improve Exception Handling & Behaviour in Callbacks
- Uses cases for below HiveMQ success codes HOT 3
- Capture WSS with Proxyman
- Slow Initial Data Transmission Issue in MQTT Client HOT 5
- $share/group/pubq HOT 4
- Mqtt5DisconnectException: Exception while decoding PUBLISH: topic alias must not exceed topic alias maximum HOT 2
- The field `responseTopic` of the class `Mqtt5Publish` returns the fulfilled optional with value `null`
- Async Mqtt3Client does not release threads created by publishes() when disconnected HOT 11
- Can not connect to HiveMQ WebSocket Client HOT 2
- DNS over HTTPS On Android HOT 1
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 hivemq-mqtt-client.