Skip to content
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

MqttSubscriptionClient: connection lost #22

Closed
turswolm opened this issue Jul 9, 2018 · 14 comments
Closed

MqttSubscriptionClient: connection lost #22

turswolm opened this issue Jul 9, 2018 · 14 comments
Assignees
Labels
closing-soon pending-response Issue is pending response from the issue requestor

Comments

@turswolm
Copy link

turswolm commented Jul 9, 2018

Hi,

I'm facing a problem when using subscriptions with Android SDK. When I start my app subscriptions work well for some time (about 1 min). After this time connection is lost and not established any more. It seams that this happens always when I restart my app but I have not figured out a predictable behavior or why this happens.

With my JS client I don't have this issue. So I tried your sample app https://github.com/aws-samples/aws-mobile-appsync-events-starter-android and I have the same issue.

07-09 07:07:50.995 2734-3072/com.amazonaws.deepdish.postsgraphql D/AlarmPingSender: Schedule next alarm at 1531120071095
    Alarm scheule using setExactAndAllowWhileIdle, next: 100
07-09 07:07:51.332 2734-2734/com.amazonaws.deepdish.postsgraphql D/ViewEventActivity: Wrote comment to database
07-09 07:07:51.429 2734-2734/com.amazonaws.deepdish.postsgraphql D/MqttSubscriptionClient: connection lost
07-09 07:07:51.429 2734-2734/com.amazonaws.deepdish.postsgraphql D/ViewEventActivity: Subscription completed

I'm using the latest version of this SDK (2.6.21) but also faced the problem with earlier versions.

Thx in advance for your answer.

@minbi
Copy link
Contributor

minbi commented Jul 9, 2018

Hi @turswolm ,

The logs show that the subscription is completed which means in the onCompleted method you can either choose to allow the subscription to end or restart the subscription.

@turswolm
Copy link
Author

Thank you for your quick response.

I don't think that it's designed behavior that a subscription ends unexpected after some time and I have to subscribe again in the onCompleted() method. In my opinion a subscription should last until I unsubscribe.

The question is, why the connection is lost again and again and why no reconnect is done. I can see no reason. My app (or even the Android emulator) is connected via Wifi and says in the Wifi.

In MqttSubscriptionClient in the MqttCallback a java.io.EOFException with message null is passed as cause in the connectionLost() method.

@leangl
Copy link

leangl commented Aug 6, 2018

Same problem here. I have narrowed the problem to Android 8.0 or greater. Also when restarting subscription sometimes it throws a ConcurrentModificationException.

@minbi
Copy link
Contributor

minbi commented Aug 6, 2018

Hi @lglossman ,

Can you provide a stacktrace for the ConcurrentModificationException?

@leangl
Copy link

leangl commented Aug 7, 2018

@minbi

java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextNode(HashMap.java:1441) at java.util.HashMap$KeyIterator.next(HashMap.java:1465) at com.amazonaws.mobileconnectors.appsync.subscription.RealSubscriptionManager$1.onError(RealSubscriptionManager.java:193) at com.amazonaws.mobileconnectors.appsync.subscription.mqtt.MqttSubscriptionClient$ClientConnectionListener.connectionLost(MqttSubscriptionClient.java:184) at org.eclipse.paho.android.service.MqttAndroidClient.connectionLostAction(MqttAndroidClient.java:1469) at org.eclipse.paho.android.service.MqttAndroidClient.onReceive(MqttAndroidClient.java:1390) at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:311) at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:47) at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:120) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

@leangl
Copy link

leangl commented Aug 8, 2018

@minbi Is onError a terminal event? I ask this because I need to restart the subscription and I'm not sure if i should be doing that on both onComplete and onError.

@minbi
Copy link
Contributor

minbi commented Aug 10, 2018

@lglossman ,
The concurrent modification issue should be fixed with version 2.6.24.
The onComplete will signal that the subscription has completed due to cancellation or a connection loss.

@dabeidl
Copy link

dabeidl commented Aug 14, 2018

How can I distinguish between the two cases that the subscription has completed due to cancellation or a connection loss?

@mutablealligator
Copy link

@turswolm @lglossman @dabeidl What versions of Paho client and MQTT Service client are you using?

@dabeidl
Copy link

dabeidl commented Aug 31, 2018

org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0,
org.eclipse.paho:org.eclipse.paho.android.service:1.1.1
and com.amazonaws:aws-android-sdk-appsync:2.6.25

@mutablealligator
Copy link

@dabeidl Can you try using 1.1.0 version of org.eclipse.paho:org.eclipse.paho.client.mqttv3 library?

olga-dorogan pushed a commit to olga-dorogan/aws-mobile-appsync-sdk-android that referenced this issue Sep 13, 2018
olga-dorogan pushed a commit to olga-dorogan/aws-mobile-appsync-sdk-android that referenced this issue Sep 14, 2018
…ver it values and ConcurrentModificationException throw (awslabs#22)
olga-dorogan pushed a commit to olga-dorogan/aws-mobile-appsync-sdk-android that referenced this issue Sep 14, 2018
@scb01 scb01 self-assigned this Sep 14, 2018
@scb01
Copy link
Contributor

scb01 commented Sep 24, 2018

@turswolm @dabeidl
The latest rev of the SDK (2.6.26) contains a fix for the dropped connections. Can you try it out and let us know how it goes.

@scb01 scb01 added the pending-response Issue is pending response from the issue requestor label Sep 24, 2018
@scb01
Copy link
Contributor

scb01 commented Oct 3, 2018

@turswolm @dabeidl @lglossman

Just checking back to see if you are still facing the issues with the new rev of the SDK.

@scb01
Copy link
Contributor

scb01 commented Oct 12, 2018

@turswolm @dabeidl @lglossman
I am going to go ahead and close this issue. Please feel free to reopen if you are still facing issues.

@scb01 scb01 closed this as completed Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon pending-response Issue is pending response from the issue requestor
Projects
None yet
Development

No branches or pull requests

7 participants