We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am trying to create mqtt message from code and then publish it.
But in PublishListener event when I am trying get payload this exception io.netty.util.IllegalReferenceCountException: refCnt: 0 throws every time.
Here is my code: _mqttBroker = new Server(); final List<? extends InterceptHandler> userHandlers = Arrays.asList(new PublisherListener()); _mqttBroker.startServer(server_config, userHandlers); String clientID = "a2bae31a-6c4f-4076-ae66-5aadf3668b0a"; MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, false, MqttQoS.AT_LEAST_ONCE, false, 0); MqttPublishVariableHeader headerTopic = new MqttPublishVariableHeader(topic, 0); ByteBuf anypayload = Unpooled.wrappedBuffer(data.getBytes()); MqttPublishMessage msg = new MqttPublishMessage(mqttFixedHeader, headerTopic, anypayload); _mqttBroker.internalPublish(msg, clientID); InterceptPublishMessage message = new InterceptPublishMessage(msg, clientID, clientID); new PublisherListener().onPublish(message);
public void onPublish(InterceptPublishMessage message) { System.out.println("moquette mqtt broker message intercepted, topic: " + message.getTopicName() + ", content: "); System.out.println(message.getPayload()); byte[] bytes = new byte[message.getPayload().readableBytes()]; message.getPayload().duplicate().readBytes(bytes); System.out.println(new String(bytes)); SensorContext.MessageRecieved(message); }
moquette-broker-0.15
java -version
1.8.0_312
uname -a
Ubuntu 20
The text was updated successfully, but these errors were encountered:
The code you posted is very incomplete. Can you make a self-contained test that shows the issue?
Sorry, something went wrong.
No branches or pull requests
Expected behavior
I am trying to create mqtt message from code and then publish it.
Actual behavior
But in PublishListener event when I am trying get payload this exception io.netty.util.IllegalReferenceCountException: refCnt: 0 throws every time.
Steps to reproduce
Here is my code:
_mqttBroker = new Server();
final List<? extends InterceptHandler> userHandlers = Arrays.asList(new PublisherListener());
_mqttBroker.startServer(server_config, userHandlers);
String clientID = "a2bae31a-6c4f-4076-ae66-5aadf3668b0a";
MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, false, MqttQoS.AT_LEAST_ONCE, false, 0);
MqttPublishVariableHeader headerTopic = new MqttPublishVariableHeader(topic, 0);
ByteBuf anypayload = Unpooled.wrappedBuffer(data.getBytes());
MqttPublishMessage msg = new MqttPublishMessage(mqttFixedHeader, headerTopic, anypayload);
_mqttBroker.internalPublish(msg, clientID);
InterceptPublishMessage message = new InterceptPublishMessage(msg, clientID, clientID);
new PublisherListener().onPublish(message);
public void onPublish(InterceptPublishMessage message) {
System.out.println("moquette mqtt broker message intercepted, topic: " + message.getTopicName()
+ ", content: ");
System.out.println(message.getPayload());
byte[] bytes = new byte[message.getPayload().readableBytes()];
message.getPayload().duplicate().readBytes(bytes);
System.out.println(new String(bytes));
SensorContext.MessageRecieved(message);
}
Moquette MQTT version
moquette-broker-0.15
JVM version (e.g.
java -version
)1.8.0_312
OS version (e.g.
uname -a
)Ubuntu 20
The text was updated successfully, but these errors were encountered: