-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
com.amazonaws.AmazonClientException: Unable to execute HTTP request: Read timed out #567
Comments
It case app crash. I tried to catch this exception, but I couldn't capture it. |
@zhouxuemeng1988 Sorry for the delayed response. This issue happens when the network connectivity is poor/lost. You can grab this exception by looking into the callback that you attach to the connect method. The callback will be invoked with |
@kvasukib how I can attach listener for that callback? My stacktrace: com.amazonaws.AmazonClientException: Unable to execute HTTP request: Unable to resolve host "cognito-identity.eu-central-1.amazonaws.com": No address associated with hostname
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:441)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:212)
at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.invoke(AmazonCognitoIdentityClient.java:566)
at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.getId(AmazonCognitoIdentityClient.java:448)
at com.amazonaws.auth.AWSAbstractCognitoIdentityProvider.getIdentityId(AWSAbstractCognitoIdentityProvider.java:172)
at com.amazonaws.auth.AWSEnhancedCognitoIdentityProvider.refresh(AWSEnhancedCognitoIdentityProvider.java:76)
at com.amazonaws.auth.CognitoCredentialsProvider.startSession(CognitoCredentialsProvider.java:678)
at com.amazonaws.auth.CognitoCredentialsProvider.getCredentials(CognitoCredentialsProvider.java:465)
at com.amazonaws.auth.CognitoCachingCredentialsProvider.getCredentials(CognitoCachingCredentialsProvider.java:485)
at com.amazonaws.auth.CognitoCachingCredentialsProvider.getCredentials(CognitoCachingCredentialsProvider.java:77)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:5200)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.scan(AmazonDynamoDBClient.java:2481)
at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.scan(DynamoDBMapper.java:2264)
at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.scan(DynamoDBMapper.java:2228) |
@tajchert What version of the SDK are you using? Can you post the contents of your |
@kvasukib
|
@tajchert Thank you for the confirmation. Regardless, the SDK should be catching the exception and throwing it back to the application when the network call is made on the background thread. We will look into it. Can you post a sample code snippet right from where you create the credentials provider till the scan call is made? (Exclude the AWS configuration/sensitive information). |
@kvasukib I have already handled this throwable callback, but it still crash my app. try {
credentialsProvider = new CognitoCachingCredentialsProvider(
WXEnvironment.getApplication().getApplicationContext(),
cognito_pool_id,
Regions.fromName(region)
);
mqttManager = new AWSIotMqttManager(clientId, end_point);
mqttManager.connect(credentialsProvider, new AWSIotMqttClientStatusCallback() {
@Override
public void onStatusChanged(final AWSIotMqttClientStatus status,
final Throwable throwable) {
checkConnectionTime = System.currentTimeMillis();
statusCallBack = "Disconnected";
if (status == AWSIotMqttClientStatus.Connecting) {
Log.e(LOG_TAG, "Connecting...");
statusCallBack = "Connecting";
} else if (status == AWSIotMqttClientStatus.Connected) {
Log.e(LOG_TAG, "Connected");
checkConnectionTime = System.currentTimeMillis();
statusCallBack = "Connected";
} else if (status == AWSIotMqttClientStatus.Reconnecting) {
if (throwable != null) {
Log.e(LOG_TAG, "Connection error.", throwable);
}
statusCallBack = "Reconnecting";
Log.e(LOG_TAG, "Reconnecting");
} else if (status == AWSIotMqttClientStatus.ConnectionLost) {
if (throwable != null) {
Log.e(LOG_TAG, "Connection error.", throwable);
throwable.printStackTrace();
}
statusCallBack = "ConnectionLost";
Log.e(LOG_TAG, "Connection lost");
} else {
Log.e(LOG_TAG, "Disconnected");
}
if (stateLisenter != null) {
stateLisenter.onStateChange(statusCallBack);
}
}
});
} catch (AmazonClientException e) {
Log.e(LOG_TAG, "Connection AmazonClientException111.", e);
} catch (Exception e) {
Log.e(LOG_TAG, "Connection error1111.", e);
} |
@zhouxuemeng1988 I have changed your code to look for the exception from the callback. try {
credentialsProvider = new CognitoCachingCredentialsProvider(
WXEnvironment.getApplication().getApplicationContext(),
cognito_pool_id,
Regions.fromName(region)
);
mqttManager = new AWSIotMqttManager(clientId, end_point);
mqttManager.connect(credentialsProvider, new AWSIotMqttClientStatusCallback() {
@Override
public void onStatusChanged(final AWSIotMqttClientStatus status,
final Throwable throwable) {
if (throwable != null) {
Log.d("", throwable.getMessage());
if (throwable instanceof AmazonClientException) {
} else if (throwable instanceof MqttException) {
} else if (throwable instanceof Exception) {
}
}
checkConnectionTime = System.currentTimeMillis();
statusCallBack = "Disconnected";
if (status == AWSIotMqttClientStatus.Connecting) {
Log.e(LOG_TAG, "Connecting...");
statusCallBack = "Connecting";
} else if (status == AWSIotMqttClientStatus.Connected) {
Log.e(LOG_TAG, "Connected");
checkConnectionTime = System.currentTimeMillis();
statusCallBack = "Connected";
} else if (status == AWSIotMqttClientStatus.Reconnecting) {
if (throwable != null) {
Log.e(LOG_TAG, "Connection error.", throwable);
}
statusCallBack = "Reconnecting";
Log.e(LOG_TAG, "Reconnecting");
} else if (status == AWSIotMqttClientStatus.ConnectionLost) {
if (throwable != null) {
Log.e(LOG_TAG, "Connection error.", throwable);
throwable.printStackTrace();
}
statusCallBack = "ConnectionLost";
Log.e(LOG_TAG, "Connection lost");
} else {
Log.e(LOG_TAG, "Disconnected");
}
if (stateLisenter != null) {
stateLisenter.onStateChange(statusCallBack);
}
}
});
} catch (AmazonClientException e) {
Log.e(LOG_TAG, "Connection AmazonClientException111.", e);
} catch (Exception e) {
Log.e(LOG_TAG, "Connection error1111.", e);
} |
@kvasukib Thanks for your response, but I think doing this just prints the error log and doesn't solve the real crash. |
@zhouxuemeng1988 The issue you're getting is because of a slow/stale connection. You can set |
@kvasukib I did not set the relevant default values. I looked at the AWSlotMqttManager source and found one of the following default values: autoReconnect=true, needResubscribe=trueminReconnectRetryTime=4, maxReconnectRetryTime=64, maxAutoReconnectAttempts=10. The automatic reconnection has been set by default. I think that when the network is not good, the mqtt connection loss is acceptable, but should not crash my entire app.Thank you. |
@zhouxuemeng1988 Can we setup a call to discuss the issue further? You can email me at karthba at amazon dot com. |
@zhouxuemeng1988, we have not heard from you. Please reach out to @kvasukib via email so we can setup a call to diagnose the issue. |
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems. |
I am facing the same issue is there any solution? |
12/17/2019 17:28:13 : SEVERE : Unable to fetch message text from input message. |
I'm having the same issue. Any update? |
I'm having the same issue. What is wrong? |
I am facing the same issue. No Idea, why it's happening. The Internet connection seems to be working fine. |
Same issue. Whats the update. In my case I think its because of a hook that runs when the user gets confirmed so it causes a delay in the response |
A lot of my user are reporting this problem with S3 service with stable network connections (wifi) |
*I only initialized aws related services after requesting our own server, so the user's network should be good.
*aws lot mqtt
*sdk version: 2.6.28
Device Information (please complete the following information):
FINGERPRINT=DPT/public_talent_3751V500/public_talent_3751V500:4.4.2/BOE/20170915.194347:eng/dev-keys
HARDWARE=hi3751
UNKNOWN=unknown
RADIO=unknown
BOARD=bigfish
versionCode=75
PRODUCT=public_talent_3751V500
versionName=3.1.4
DISPLAY=BOE_iGallery32_V_dfjh1.01
USER=leidongdong
HOST=leidongdong
DEVICE=public_talent_3751V500
TAGS=dev-keys
MODEL=5V10-C-CWQX
BOOTLOADER=unknown
CPU_ABI=armeabi-v7a
CPU_ABI2=armeabi
IS_DEBUGGABLE=true
devicesId=2208caebb5b77853
ID=BOE
SERIAL=unknown
MANUFACTURER=Talent
BRAND=DPT
TYPE=eng
Additional context
The text was updated successfully, but these errors were encountered: