Aws-sdk-android: Got "Could not create epoll instance: Too many open files" error after ~150 unsuccessful reconnecting attempts

Created on 31 Mar 2019  路  3Comments  路  Source: aws-amplify/aws-sdk-android

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:

  1. Succesfully connect the AWSIotMqttManager with AWS with autoReconnect enabled

I use this settings:

  manager.setMaxAutoReconnectAttepts(-1)
  manager.keepAlive = 0
  manager.setReconnectRetryLimits(1, 8)
  1. Turn off the internet connection
  2. AWSIotMqttManager tries to reconnect, after ~100-300 attempts to reconnect the app crashes with the following errors:
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

  • Android Version: 8.0
  • Specific to simulators: no

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?

Bug IoT

All 3 comments

@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.

Was this page helpful?
0 / 5 - 0 ratings