Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a judgment on QoS in the publish method #115

Open
xyangwang opened this issue Dec 26, 2018 · 0 comments
Open

Add a judgment on QoS in the publish method #115

xyangwang opened this issue Dec 26, 2018 · 0 comments

Comments

@xyangwang
Copy link

I use this component as a broker, and use the eclipse paho client receive message from broker.
I found that using the MqttEndpoint publish method to send messages to clients, regardless of whether the QoS is 0 or not, each time it get the next message ID. But if paho client receive a message with QoS 0, its message ID is 0.

MqttPublishVariableHeader variableHeader =
      new MqttPublishVariableHeader(topic, this.nextMessageId());

I write an example, one client send a message with QoS 0 and next time send a message with QoS 1 to the other, loop this function 10 times.

for (int i = 0; i < 10; ++i) {
      mqttClient.publish(testTopic, "hello".getBytes(), 0, false);
      mqttClient.publish(testTopic2, "world".getBytes(), 1, false);
}

the receive client console log:

mqtt client is connected.
----connect complete-----
false : tcp://127.0.0.1:1886
message id = 0, qos = 0, payload = hello
1
message id = 2, qos = 1, payload = world
2
message id = 0, qos = 0, payload = hello
3
message id = 4, qos = 1, payload = world
4
message id = 0, qos = 0, payload = hello
5
message id = 6, qos = 1, payload = world
6
message id = 0, qos = 0, payload = hello
7
message id = 8, qos = 1, payload = world
8
message id = 0, qos = 0, payload = hello
9
message id = 10, qos = 1, payload = world
10
message id = 0, qos = 0, payload = hello
11
message id = 12, qos = 1, payload = world
12
message id = 0, qos = 0, payload = hello
13
message id = 14, qos = 1, payload = world
14
message id = 0, qos = 0, payload = hello
15
message id = 16, qos = 1, payload = world
16
message id = 0, qos = 0, payload = hello
17
message id = 18, qos = 1, payload = world
18
message id = 0, qos = 0, payload = hello
19
message id = 20, qos = 1, payload = world
20

I think it's necessary to add a judgment on QoS in the publish method to prevent the client from receiving discontinuous message IDs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant