int max_connections =10000;
String broker = "tcp://xxx.xxx.x.xx:1883";
String clientId = "Publisher";
String content="Hii";
int qos=1;
String topic="Cluster";
MemoryPersistence persistence = new MemoryPersistence();
MqttClient sampleClient[] = new MqttClient[max_connections];
Thread t[] = new Thread[max_connections];
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setCleanSession(true);
for (int i = 0; i < max_connections; i++) {
try {
sampleClient[i] = new MqttClient(broker, clientId + "" + i, persistence);
sampleClient[i].connect(connOpts);
} catch (MqttException ex) {
ex.printStackTrace();
return;
}
}
I'm using RabbitMq 3.6.6 with paho.mqttv3 protocol my simple code like
I'm Getting Exception Like : Exception in thread "MQTT Con: Publisher2919" java.lang.OutOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:714) at org.eclipse.paho.client.mqttv3.internal.CommsSender.start(CommsSender.java:60) at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:654) at java.lang.Thread.run(Thread.java:745) |
My system RAM is 8 GB with Corei5 Processor.
so any OS level Configuration in Ubuntu to make more Connection?