Android - Signing-in with AWS is suddenly incredibly slow

I'm making an Android app that uses AWS Cognito to sign users in. I based the sign-in flow off of the sample app/Cognito YourUserPools samples on AWS' github and tweaked it and it's been working fine for months. Out of nowhere, when launching the app it hangs on the splash screen during the authentication flow, and when signing-out and back in it will just stay on the sign-in screen (the activity is still responsive). After about 2-3 mins it will launch my home screen activity.

I've rolled back to a previously working build and this issue is still present. I've also tried completely uninstalling the app, restarting my phone, cleaning/making/rebuilding the project, everything.

Here's the log:

01-19 21:41:31.312 25819-25819/[my package] I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
01-19 21:41:31.581 25819-25819/[my package] I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
01-19 21:41:31.830 25819-28371/[my package] D/libc: getaddrinfo called from pid =25819
01-19 21:41:31.830 25819-28371/[my package] D/libc: getaddrinfo called from pid =25819
01-19 21:42:17.125 25819-28371/[my package] D/libc: getaddrinfo called from pid =25819
01-19 21:42:17.879 25819-25819/[my package] I/CognitoUserPoolsSignInProvider: Logged in. com.amazonaws.mobileconnectors.cognitoidentityprovider.tokens.CognitoIdToken@e63bbed
01-19 21:42:17.880 25819-25819/[my package] D/IdentityManager: SignInProviderResultAdapter.onSuccess(): Amazon Cognito Your User Pools provider sign-in succeeded.
01-19 21:42:17.880 25819-25819/[my package] D/IdentityManager: federateWithProvider
01-19 21:42:17.907 25819-25819/[my package] D/CognitoCachingCredentialsProvider: Loading credentials from SharedPreferences
01-19 21:42:17.907 25819-25819/[my package] D/CognitoCachingCredentialsProvider: No valid credentials found in SharedPreferences
01-19 21:42:17.908 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Clearing credentials from SharedPreferences
01-19 21:42:17.908 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Identity id is changed
01-19 21:42:17.908 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Saving identity id to SharedPreferences
01-19 21:42:17.908 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Clearing credentials from SharedPreferences
01-19 21:42:17.908 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Clearing credentials from SharedPreferences
01-19 21:42:17.909 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Clearing credentials from SharedPreferences
01-19 21:42:17.909 25819-26030/[my package] D/IdentityManager: refresh credentials
01-19 21:42:17.909 25819-26030/[my package] D/AWSRefreshingCognitoIdentityProvider: Refreshing token...
01-19 21:42:17.917 25819-26030/[my package] D/libc: getaddrinfo called from pid =25819
01-19 21:42:17.917 25819-26030/[my package] D/libc: getaddrinfo called from pid =25819
01-19 21:44:18.147 25819-26030/[my package] D/libc: getaddrinfo called from pid =25819
01-19 21:44:18.367 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Identity id is changed
01-19 21:44:18.367 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Saving identity id to SharedPreferences
01-19 21:44:18.367 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Clearing credentials from SharedPreferences
01-19 21:44:18.480 25819-26030/[my package] D/AWSRefreshingCognitoIdentityProvider: Refreshing token...
01-19 21:44:18.741 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Saving credentials to SharedPreferences
01-19 21:44:18.742 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Saving identity id to SharedPreferences
01-19 21:44:18.889 25819-26030/[my package] D/CognitoCachingCredentialsProvider: Saving credentials to SharedPreferences
01-19 21:44:18.891 25819-26030/[my package] D/IdentityManager: Cognito ID: [MY COGNITO ID]
01-19 21:44:18.893 25819-26030/[my package] D/IdentityManager: Cognito Credentials: com.amazonaws.auth.BasicSessionCredentials@a076a22
01-19 21:44:18.909 25819-26030/[my package] D/IdentityManager: SignInProviderResultAdapter.onCognitoSuccess()
01-19 21:44:18.910 25819-25819/[my package] I/SignInActivity: Sign-in with Amazon Cognito Your User Pools succeeded.
01-19 21:44:18.910 25819-26864/[my package] D/IdentityManager: Retrieving user info and image from identity provider.

Apparently this all takes 2:49 now! Why are things being completed in blocks with the blocks so far apart? And specifically, why does this getaddrinfo called from pid =25819 happen in the pattern of "the first 2 instantaneously, then 1 more way later"? This occurred twice; in occurrence #1 that 3rd call came 46 sec later and in occurrence #2 it came 2 mins later.

Is this on Amazon's end? I use the same user pool for an iOS app and there are no sign-in problems on that platform. Let me know if I need to supply more information, as this isn't my typical coding problem.


Solution 1:

I can't believe it, but the problem is my internet connection (I suspect my router). I disabled wifi on my phone and was able to complete sign-in normally! The standard "unplug the modem/router for 10 sec and plug back in" solution didn't fix this.

I suspect that after so many time signing-in with the same request made to the same place my router started calling it malicious. I'm still uncertain as to what the real problem is, but it's not with code nor with AWS. Ugh.

I'm leaving this as the answer on the off-chance it ever benefits another human being.