我想对mosquitto进行压力测试,所以我创建了一些代码如下
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();
}
但是,我EOFException
在运行期间遇到了一些错误,并且某些客户端断开了连接。我想知道一台mosquitto服务器可以同时发布多少个客户端,如何进行压力测试。谢谢!
详细例外是:
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
我从 mosquitto 服务器上找到了一些日志:
1383736170: Socket read error on client Server-82, disconnecting.
请帮助我,谢谢!