[英]MQTT PUBACK web sockets
I'm working on HiveMQ Websocket Client
and I'm facing some issues with the message delivery
. 我正在使用
HiveMQ Websocket Client
并且在message delivery
HiveMQ Websocket Client
一些问题。 so, I've come across the word PUBACK
所以,我遇到了
PUBACK
这个词
let me explain you about my understanding and then I will ask my question. 让我向您解释一下我的理解,然后我会问我的问题。
whenever we send a message with QOS1
, the hivemq server will acknowledge the sender with a PUBACK
callback. 每当我们使用
QOS1
发送消息时,hivemq服务器都会通过PUBACK
回调确认发送者。
Now, I'm planning to subscibe to onPubackReceived event in my websockets, but the event is not firing after sending the message. 现在,我打算订阅我的Web套接字中的onPubackReceived事件,但是该事件在发送消息后不会触发。
My Code: 我的代码:
var clientId = ClientIdentifier;
mqtt = new Messaging.Client(
host,
port,
clientId);
var options = {
timeout: 3,
keepAliveInterval: 60,
useSSL: useTLS,
cleanSession: cleansession,
onSuccess: onConnect,
onFailure: function (message) {
connected = false;
setTimeout(MQTTconnect, reconnectTimeout);
}
};
mqtt.onConnectionLost = onConnectionLost;
mqtt.onMessageArrived = onMessageArrived;
mqtt.onPubackReceived = OnPubackReceived;
Both the onConnectionLost
and onMessageArrived
are firing properly when a connection lost and message arrived, but the onPubackReceived
is not firing. 当连接断开并且消息到达时,
onConnectionLost
和onMessageArrived
都将正确触发,但是onPubackReceived
不会触发。
please let me know, if I have understood it correctly or if I'm doing some mistake? 请让我知道,如果我对它的理解正确,或者我做错了什么?
This not a HiveMQ issue. 这不是HiveMQ问题。
My assumption is, that you used the HiveMQ Websocket Client as a starting point for your implementation. 我的假设是,您使用HiveMQ Websocket客户端作为实现的起点。
In any case a Paho MQTT Client does not have a onPubackReceived
field. 无论如何, Paho MQTT客户端都没有
onPubackReceived
字段。 If you provide more details about your use case or what's your issue with message delivery, I might be able to point you into the right direction. 如果您提供有关您的用例的更多详细信息,或者您在消息传递中遇到什么问题,我也许可以为您指明正确的方向。
EDIT: What you are describing is called Quality of Service 1
in MQTT. 编辑:您所描述的在MQTT中称为
Quality of Service 1
。 It is a guarantee, that a message is received at least once . 可以保证至少收到一次消息。 It is the client implementation's job to keep this guarantees and therefor resend a message, should a
PUBACK
not be received. 保持此保证并因此重新发送消息是客户端实现的工作,如果没有收到
PUBACK
。 Manually interfering with this behaviour in your application would result in inconsistency regarding the client's persistence. 在您的应用程序中手动干预此行为将导致客户端的持久性不一致。 For clarification: Simply setting
duplicate=true
will not result in a message being recognised as a duplicate. 为了澄清起见:只需将
duplicate=true
设置将不会导致消息被识别为重复项。 It will also have to have the the same messageID
as the original. 它还必须具有与原始
messageID
相同的messageID
。 I was not able to actually find any documentation about paho.js
keeping the Quality of Service = 1. However, MQTT.js does. 我实际上找不到关于
paho.js
任何文档, paho.js
包含Quality of Service =1。但是, MQTT.js可以。
QoS 1 : received at least once : The packet is sent and stored as long as the client has not received a confirmation from the server.
QoS 1:至少接收一次:只要客户端未从服务器收到确认,就发送和存储数据包。 MQTT ensures that it will be received, but there can be duplicates.
MQTT确保将其接收,但是可以重复。
To sum things up: 总结一下:
MQTT.js
works over Websockets and ensures to keep QoS levels
MQTT.js
可在Websocket上使用,并确保保持QoS levels
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.