我使用的RabbitMQ 3.6.6與paho.mqttv3協議 我簡單的代碼一樣的RabbitMQ與Mqqt協議與Ubuntu
int max_connections =400000;
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;
}
}
我得到異常喜歡:
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)
我的系統使用Corei5處理器的RAM爲8 GB。
I have also try in Windows PC in that same Error but Its Upto 7k Connection
so any OS level Configuration in Ubuntu to make more Connection?
感謝Hardlib您的快速反應,是的,我aggree與你我試圖測試多連接..但MQTT經紀人只能創建連接高達3K .....是有可能創造比這更多? –
錯誤消息是關於每個線程使用的內存量,在3000消耗的內存量超過了您的機器或操作系統允許的任何給定進程數 – hardillb
是的這是內存問題,我試圖增加RabbitMq Config文件中的「高水位」,但仍然無法連接超過3000個連接。就像你說的那樣使用Distribute運行,我怎麼能得到這個? –