Description
Describe the bug
I encountered a problem in the AWS SDK for Android that took me a long time to understand how it happened. Today, after a few years, I discovered how to reproduce the problem.
The problem occurs when the smartphone is connected to a Wi-Fi network that has no internet access, but the Android did not detect that there is a problem in the network.
The bug is that any request that I make using the SDK to fetch some data (Cognito, IoT Core, DynamoDB, etc.) has no return from the SDK, and the application simply freezes.
To Reproduce
Connect the android to a wifi network without connection, but the android cannot detect that there is a problem with the wifi. To simulate the problem here I created a rule in my router to block packets. The android takes about 5 minutes to detect that there is a problem with the wifi network and that's where all the problems occur.
An example of a request that causes the problem is:
userPool.getCurrentUser().getDetailsInBackground(handler);
When invoking this method, nothing is returned (no error, no success, no failure, no timeout). Debugging inside this method, I found out that it invokes the method:
private CognitoUserDetails getUserDetailsInternal(CognitoUserSession session) {
if (session != null && session.isValid()) {
final GetUserRequest getUserRequest = new GetUserRequest();
getUserRequest.setAccessToken(session.getAccessToken().getJWTToken());
final GetUserResult userResult = cognitoIdentityProviderClient.getUser(getUserRequest);
return new CognitoUserDetails(new CognitoUserAttributes(userResult.getUserAttributes()),
new CognitoUserSettings(userResult.getMFAOptions()));
} else {
throw new CognitoNotAuthorizedException("user is not authenticated");
}
}
The exact point where the application freezes is in:
GetUserResult userResult = cognitoIdentityProviderClient.getUser(getUserRequest);
Which AWS service(s) are affected?
I use Cognito, IoT Core, DynamoDB services and they are all affected. I think any service will be affected.
Expected behavior
The request should return a timeout error, but this does not happen.
Environment Information:
- AWS Android SDK Version: 2.73.0
- Device: Pixel, Simulator, Samsung S3 (any device)
- Android Version: Android 9, 10, 11, 12 (any version)
- Specific to simulators: No
Additional context
I need to highlight that Android needs to be on a WiFi network that does not have access to the internet, but Android cannot detect that there is a problem with the network.
When Android detects that there is a problem on the network, the SDK returns a failure (which is expected)
An important detail is also that the problem also occurs on networks that do not support IPv6