java.io.eofexception,带有paho的java.io.EOFException

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值