Thanks for your all development projects in advance.
Our project is currently use java mqtt broker, the issue now was when the server-----producing application (publisher) ,publishes the message to clients. If there is certain amount of clients (around 20), the error "too many publishes in progress" will come out even I manually set the max_in_flight value to 100.
public synchronized void send(Packet packet) {
if(_mqttClient == null || _mqttClient.isConnected() == false) {
_worker.log(TAG, "Error: mqtt client offline.");
return;
}
try {
MqttTopic topic = _mqttClient.getTopic(packet.getTopicName());
String msg = packet.getMessage();
MqttMessage message = new MqttMessage(msg.getBytes());
message.setQos(2);
msg = Packet.logify(msg, packet._type, packet.getToken());
_worker.log(TAG, "<mqtt-snd topic='" + topic.getName() + "'>" + msg + "</mqtt-snd>");
topic.publish(message);
/*MqttDeliveryToken resp = */
/*resp.waitForCompletion(10000);*/
}
catch (MqttException exception) {
_worker.log(TAG, exception.getMessage());
_worker.log(TAG, "Error: mqtt send packet failed: < " + packet.getMessage() + " >");
} catch (Exception e) {
e.printStackTrace();
}
}