aws-amplify / aws-sdk-android

AWS SDK for Android. For more information, see our web site:
https://docs.amplify.aws
Other
1.03k stars 549 forks source link

Client is not connected . SubscribeToTopic failed. #3640

Open ranjeet-porter opened 1 month ago

ranjeet-porter commented 1 month ago

After connecting connection is suddenly lost and while subscribing topic sdk is throwing error.

onSuccess: mqtt connection is successful. 2024-09-19 09:45:54.162 Init 7ffd018 [AndroidXMedia3/1.4.1] [m51, SM-M515F, samsung, 31] 2024-09-19 09:45:54.163 MQTT: Status-> Connected, Throwable-> null 2024-09-19 09:45:54.164 MQTT: subscribeToTopic called 2024-09-19 09:45:54.166 MQTT-> connectionStatus: in.porter.kmputils.communication.mqtt.entities.responses.MqttConnectionStatus$MqttConnectionConnected@3e31a71 2024-09-19 09:45:54.177 MQTT: subscribeToTopic called 2024-09-19 09:45:54.178 onSuccess: mqtt connection is successful. 2024-09-19 09:45:54.179 connection is Lost 2024-09-19 09:45:54.180 schedule Reconnect attempt 0 of 40 in 4 seconds. 2024-09-19 09:45:54.185 MQTT: Status-> Connected, Throwable-> null 2024-09-19 09:45:54.186 MQTT-> connectionStatus: in.porter.kmputils.communication.mqtt.entities.responses.MqttConnectionStatus$MqttConnectionConnected@3e31a71 2024-09-19 09:45:54.200 MQTT: subscribeToTopic called 2024-09-19 09:45:54.274 MQTT: subscription SUCCESSFUL topic:staging/communication/push-notification/driver/aws_6666666612000_staging 2024-09-19 09:45:54.274 MQTT: Status-> Reconnecting, Throwable-> Connection lost (32109) - java.io.EOFException 2024-09-19 09:45:54.304 MQTT: subscription FAILED topic:staging/communication/push-notification/driver/aws_6666666612000_staging (Ask Gemini) Client is not connected (32104) at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:31) at org.eclipse.paho.client.mqttv3.internal.ClientComms.sendNoWait(ClientComms.java:205) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.subscribeBase(MqttAsyncClient.java:1088) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.subscribe(MqttAsyncClient.java:1061) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.subscribe(MqttAsyncClient.java:1017) at com.amazonaws.mobileconnectors.iot.AWSIotMqttManager.subscribeToTopic(AWSIotMqttManager.java:1506) at in.porter.kmputils.communication.mqtt.usecases.AwsSubscribeToTopicImpl.invoke(AwsSubscribeToTopicImpl.kt:29) at in.porter.kmputils.communication.mqtt.managers.PorterMqttManagerImpl$subscribe$2.invoke(PorterMqttManagerImpl.kt:62) at in.porter.kmputils.communication.mqtt.managers.PorterMqttManagerImpl$subscribe$2.invoke(PorterMqttManagerImpl.kt:62) at in.porter.kmputils.communication.mqtt.managers.PorterMqttManagerImpl.mqttTransact(PorterMqttManagerImpl.kt:68) at in.porter.kmputils.communication.mqtt.managers.PorterMqttManagerImpl.subscribe(PorterMqttManagerImpl.kt:62) at com.theporter.android.driverapp.http.notificationservices.mqtt.MqttNotificationService.subscribeToNotifications(MqttNotificationService.kt:58) at com.theporter.android.driverapp.http.notificationservices.mqtt.MqttNotificationService.access$subscribeToNotifications(MqttNotificationService.kt:25) at com.theporter.android.driverapp.http.notificationservices.mqtt.MqttNotificationService$register$1.invokeSuspend(MqttNotificationService.kt:47) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104) at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)

phantumcode commented 1 month ago

@ranjeet-porter Can you provide more details on the issue? What are the steps to reproduce? What versions are you using? Can you provide sample app or code that can help us reproduce the issue to investigate and troubleshoot further?

ranjeet-porter commented 1 month ago

Hi @phantumcode I am trying to connect with broker and subscribing topic aggressively and from multiple points like internet change, workmanager, app launch, activity within app so facing this issue while using app.

ranjeet-porter commented 1 month ago

MQTT: subscription FAILED topic:staging/communication/push-notification/driver/aws_6100******_staging (Ask Gemini) Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197) at java.lang.Thread.run(Thread.java:1012) Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:275) at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92) at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137) at java.lang.Thread.run(Thread.java:1012) 

when subscribe to topic called multiple times and in between it lost connectivity sdk is throwing this error

ruisebas commented 1 month ago

Please provide the following: