i want to make stress test on mosquitto, so i create some code as below
for (int i = 0; i < 800; i++) {
final int j = i;
Thread t = new Thread(new Runnable() {
@Override
public void run() {
System.out.println(j + " : ************");
try {
MqttClient client = new MqttClient("tcp://192.168.88.203", SERVER_CLIENTID_PREFIX + j);
client.connect();
MqttMessage message = new MqttMessage((j + ":me").getBytes());
message.setQos(2);
client.publish(TOPIC_PREFIX + j, message);
} catch (MqttSecurityException e) {
e.printStackTrace();
} catch (MqttException e) {
e.printStackTrace();
}
}
});
t.start();
}
But, I got some errors like EOFException
during run and some client is disconnect.
I want to know how many clients can publish messages at same time with one mosquitto server, and how can I make the stress test. Thanks!
The detail exception is :
Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:162)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:250)
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:51)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:121)
... 1 more
And I found some log from mosquitto server:
1383736170: Socket read error on client Server-82, disconnecting.
Please help me, thanks!
I got this exact same error using code similar to above. I found that changing the QOS to 0 fixed the problem.
message.setQos(0);
[Edit] A bit more digging and I discovered that the MQTT plugin for RabbitMQ doesn't support a QOS of 2. http://www.rabbitmq.com/mqtt.html