Message getting stuck

HI All,

I am using HIVE MQ Enterprise edition trial version. I have a publisher client which publishes message on receiving message from a separate client . Basically there is one client subscribing to a topic, when message is received it verifies it and then the second client publishes the message again to a different topic.

My client connection file looks something like this :

var mqtt = require('mqtt');

var options = {
    port: process.env.MQTT_PORT, // Required
    host: process.env.MQTT_HOST, // Required
    clientId: 'mqttjs_abhar_' + Math.random().toString(16).substr(2, 8), // Randomly generated ID
    username: process.env.MQTT_USERNAME, // Required
    password: process.env.MQTT_PASSWORD, // Required
    protocol: process.env.MQTT_PROTOCOL, // Required
    connectTimeout:1000,
    keepalive: 60,
};

var client = mqtt.connect(process.env.MQTT_HOST, options); 

client.on('connect', function() { // When connected
    console.log('MQTT BROKER connected');
});

module.exports=client;

The options I am using to publish messages are :

var options={
    retain:false,
    qos:1};

If I restart the whole thing it starts working properly but after sometime of being idle the messages are received by the subscriber client but not sent using the publisher client.

Thanks in advance

Hi @kaustav1996,

we have a lot of tests that verify that this should not happen. So I think I need your client code to try to reproduce your observed behaviour.

Do you have your code somewhere public (like GitHub) so that I can use that code?

And please describe your setup, that would be helpful:

  • HiveMQ version
  • do you run HiveMQ in cluster (if yes how big is the cluster)
  • do you have any extensions running (see extension folder)
  • do you see anything in log/event.log that indicates dropped messages

Greetings,
Michael from the HiveMQ team

Hi @kaustav1996,

Welcome to the HiveMQ Community Forum. Nice to see your interest in MQTT.
When I understand your post correctly you are having problems with your client implementation.
Have you reached out to client library providers and verified your code is correct?

Thanks,
Florian

Hi @kaustav1996,

since you posted JS code using MQTTjs: We use a similar tech stack a lot for some years now without problems. If you can provide more details/small repro I could have a look.

BTW: Did you check the broker logs? Just in case the second client got disconnected due to client settings (e.g. keepAlive, clientId…).

Mirko

1 Like