Describe the bug
When AWSIotMqttManager tries to reconnect, after ~100-300 attempts to reconnect the app crashes with this error:
Could not create epoll instance: Too many open files
To Reproduce
Steps to reproduce the behavior:
I use this settings:
manager.setMaxAutoReconnectAttepts(-1)
manager.keepAlive = 0
manager.setReconnectRetryLimits(1, 8)
2019-03-29 20:33:27.285 I/AWSIotMqttManager: schedule Reconnect attempt 158 of -1 in 8 seconds.
2019-03-29 20:33:31.750 I/AWSIotMqttManager: attempting to reconnect to mqtt broker
2019-03-29 20:33:31.776 W/AWSIotMqttManager: Reconnect failed
2019-03-29 20:33:31.779 I/AWSIotMqttManager: schedule Reconnect attempt 159 of -1 in 8 seconds.
2019-03-29 20:33:31.783 A/Looper: Could not create epoll instance: Too many open files
2019-03-29 20:33:31.817 W/zygote: ashmem_create_region failed for 'indirect ref table': Too many open files
2019-03-29 20:33:36.921 I/AWSIotMqttManager: attempting to reconnect to mqtt broker
2019-03-29 20:33:36.925 W/zygote: ashmem_create_region failed for 'indirect ref table': Too many open files
2019-03-29 20:33:36.925 I/AWSIotMqttManager: attempting to reconnect to mqtt broker
Which AWS service(s) are affected?
AWS IoT
Expected behavior
AWSIotMqttManager should continue to reconnect without errors
Environment Information (please complete the following information):
AWS Android SDK Version:
'com.amazonaws:aws-android-sdk-core:2.10.+'
'com.amazonaws:aws-android-sdk-iot:2.6.+'
Device: Huawei Watch 2
Additional context
The wearOS devices are used in the environment with a specific network setup which causes a huge number of reconnect attempts. So, from time to time the app crashes.
I'm wondering how to fix or avoid such crashes?
@yoshka88 Thanks for reporting the issue and sharing all the details. I will investigate the issue and post an update when I have something.
Hello, @desokroshan!
Thank you for your attention to the issue.
I've found out that when I use locally built .jar, .aar files from the sources from the master branch, everything seems to be okay.
Basically, I've changed build.gradle from this
implementation 'com.amazonaws:aws-android-sdk-core:2.10.+'
implementation 'com.amazonaws:aws-android-sdk-iot:2.6.+'
to the following
implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0"
implementation "org.conscrypt:conscrypt-android:2.0.0"
implementation files('aws-android-sdk-core.jar')
implementation files('aws-android-sdk-iot.aar')
and there is no Too many open files anymore.
Really glad, that the error disappears. However, I'm curious what is the reason for such behavior?
I've built the libraries using gradle from Android Studio with the following env variable: ANDROID_PLATFORM=27.
Could it affect anything?
Would be great, if you can share any suggestion on this matter.
Looks like this was the reason.