eclipse / paho.mqtt.android

MQTT Android
Other
2.92k stars 883 forks source link

Bug report: Too many open files #419

Open Matthew-maning opened 4 years ago

Matthew-maning commented 4 years ago

Platform: android 8.1

API version: org.eclipse.paho.client.mqttv3:1.1.1 org.eclipse.paho:org.eclipse.paho.android.service:1.1.1

Depiction:

  1. Connect to server with automatic reconnect options.
  2. Server is offline.
  3. After 14 hours, 07-04 06:01:17.286 1655 1661 W zygote64: ashmem_create_region failed for 'CompilerMetadata': Too many open files

Analysis org.eclipse.paho.client.mqttv3.internal.ConnectActionListener

public void connect() throws MqttPersistenceException { MqttToken token = new MqttToken(client.getClientId()); token.setActionCallback(this); token.setUserContext(this);

**persistence.open(client.getClientId(), client.getServerURI());**

if (options.isCleanSession()) {
  persistence.clear();
}

if (options.getMqttVersion() == MqttConnectOptions.MQTT_VERSION_DEFAULT) {
  options.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
}

try {
  comms.connect(options, token);
}
catch (MqttException e) {
  onFailure(token, e);
}

}

When connect(), open "/storage/emulated/0/Android/data/s.cscv.mqttagent/files/MqttConnection/SJ51AD20170014-ssl192168102231884/.lck" file, but not close

seaniedan commented 3 years ago

I get this error too, when using a callback: subscribe.callback(on_message_printLCD, "#", hostname="10.0.1.x", auth = {"username":"xxxxxxxx", "password":"xxxxx"}) ...all works fine for a few days then I get :

sean@enviro:~ $ sudo systemctl status enviroplus-mqtt-display.service ● enviroplus-mqtt-display.service - Enviro+ MQTT Display Loaded: loaded (/etc/systemd/system/enviroplus-mqtt-display.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2021-01-02 08:57:42 GMT; 1 weeks 6 days ago Main PID: 11241 (python3) Tasks: 1 (limit: 992) CGroup: /system.slice/enviroplus-mqtt-display.service └─11241 /usr/bin/python3 -u /home/sean/enviroplus-mqtt-display/main.py

Jan 15 15:30:26 enviro python3[11241]: error [Errno 24] Too many open files