Closed praveshkhatana closed 6 years ago
Hello @praveshkhatana
In your code snippet, you are mixing kotlin and java code.
In an Android project, you can pass 'BasicSessionCredentials' into 'AWSStaticCredentialsProvider(credentials)', like code below.
BasicSessionCredentials sessionCredentials = new BasicSessionCredentials(accessKeyId,secretAccessKey,sessionToken);
mqttManager = new AWSIotMqttManager(clientId, CUSTOMER_SPECIFIC_ENDPOINT);
mqttManager.setKeepAlive(10);
mqttManager.connect(new StaticCredentialsProvider(sessionCredentials)), new AWSIotMqttClientStatusCallback() {
@Override
public void onStatusChanged(final AWSIotMqttClientStatus status, final Throwable throwable) {
Log.d(LOG_TAG, "Status = " + String.valueOf(status));
}
});
You can implement the class StaticCredentialsProvider by yourself like the code in https://github.com/aws/aws-sdk-android/blob/master/aws-android-sdk-core/src/main/java/com/amazonaws/internal/StaticCredentialsProvider.java
@sunchunqiang Thanks for reply, Yes this is what i did and it's working fine now.
@praveshkhatana and @sunchunqiang can you provide full code for Android AWS IOT Web socket, i was try your code but it show only Reconnecting message.
No Credential Provider for BasicSession in Android.
I have user's session credentials and want to pass it to mqttManager but unable to find any suitable provider which support it. IOS version has "AWSBasicSessionCredentialsProvider" which solves the purpose.
STSSessionCredentialsProvider required long-lived credentials.
What service are you using? Auth service for IOT
In what version of SDK are you facing the problem? @2.6.+
Is the issue limited to Simulators / Actual Devices? Question
Can your problem be resolved if you bump to a higher version of SDK?
Is this problem related to specific Android/OS version? Android
Can you give us steps to reproduce with a minimal, complete, and verifiable example? Please include any specific network conditions that might be required to reproduce the problem.
mqttManager.connect(credentialsProvider, new AWSIotMqttClientStatusCallback() { @Override public void onStatusChanged(final AWSIotMqttClientStatus status, final Throwable throwable) { Log.d(LOG_TAG, "Status = " + String.valueOf(status)); } });