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
client id is the problem, generating a random test
MqttClient.generateClientId ();
There's a 1024 files/sockets limit in linux but you can upset it,ulimit -n 4096
see:
mqtt mosquitto linux connection limit
Sometimes it happen when you will try to send large data set. Try to decrease dataset size. It solved problem in my case.
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
In my case this was because I was accidentally using a tcp://...
URL instead of ssl://...
and the server was configured not to allow insecure connections.
I also had to do as @Aidan said and reduce the QoS from 2 to 1.
Edit: I'm not 100% sure, but I think the server I'm using is RabbitMQ, and that assigns a non-standard meaning to the QoS values. It's probably a more sensible meaning to be honest:
Transient (QoS0) subscription use non-durable, auto-delete queues that will be deleted when the client disconnects.
Durable (QoS1) subscriptions use durable queues. Whether the queues are auto-deleted is controlled by the client's clean session flag. Clients with clean sessions use auto-deleted queues, others use non-auto-deleted ones.
My issue resulted from the clientId being the same for the publisher/subscriber. Was getting errors with Persistence datastore already being in use as well.