-
Notifications
You must be signed in to change notification settings - Fork 554
Open
Labels
bugSomething isn't workingSomething isn't workingiotIssues with the AWS Android SDK for Internet of Things (IoT)Issues with the AWS Android SDK for Internet of Things (IoT)
Description
Subscribed topics are not getting data from MQTT
After successful connection, I am trying to connect 300 topics using for-loop. But I am receiving data from 80 topics then sometimes 60 topics. It is happening randomly so I am not able to debug it from Android Studio.
To Reproduce
A code sample or steps:
fun subscribe(context: Context, topic: AWSTopics, awsMqttListener: MqttActionListener) {
awsIotMqttManager.subscribeToTopic(topic.topicPath, AWSIotMqttQos.QOS1, object :
AWSIotMqttSubscriptionStatusCallback {
override fun onSuccess() {
LogManager.genericMessage("subscribeToTopic ${topic.topicPath} success")
awsMqttListener.onSuccess()
}
override fun onFailure(exception: Throwable?) {
LogManager.genericMessage("subscribeToTopic $topic failed")
awsMqttListener.onFailed()
}
}) { topicOnMessage, data ->
val jsonObject = data?.toString(Charsets.UTF_8)?.let { JSONObject(it) }
LogManager.genericMessage(
context,
"AWS onMessageArrived - Topic - $topicOnMessage || message ${
jsonObject?.toString(4)
}"
)
val mqttMessage = MqttMessage()
mqttMessage.payload = data
try {
val messageArrived = MessageArrived(mqttMessage, topicOnMessage)
// Get a handler that can be used to post to the main thread
val mainHandler = Handler(Looper.getMainLooper());
mainHandler.post {
messageReceivedLiveData.value = messageArrived
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
Subscribe code below:
fun subscribeToEvents(vehicleIds: List<PairedResponse.Data.Item.AssignVehicleId>, isReconnect: Boolean = false) {
// Sort and filter vehicle IDs
val sortedVehicleIds = vehicleIds.map { it.ab_id }.sorted()
Log.e("Sorted Array", "SORTED VEHICLES ::: $sortedVehicleIds")
// Subscribe to each vehicle topic sequentially
for ((position, item) in sortedVehicleIds.withIndex()) {
println("Position: $position, Vehicle abId: $item")
subscribeToTopicsSequentially(item)
}
}
Topics code:
sealed class AWSTopics(val topicPath: String) {
class EventLive(abId: String) : AWSTopics("topicName1/$abId")
class ManualResolveEvent(abId: String) : AWSTopics("topicName2/$abId")
class PairedAsset(abId: String) : AWSTopics("topicName3/$abId")
class Custom(topic: String) : AWSTopics(topic)
}
Which AWS service(s) are affected?
AWS IoT Core
Expected behavior
Expected result should be that once I subscribed to all 300+ topics, I will receive the data from all 300+ topics.
Environment Information (please complete the following information):
- AWS Android SDK Version: Android sdk version is v2.77.1
- Device: All devices
- Android Version: 8.0+ android versions
- Specific to simulators: No
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingiotIssues with the AWS Android SDK for Internet of Things (IoT)Issues with the AWS Android SDK for Internet of Things (IoT)