awslabs / awslabs/aws-mobile-appsync-sdk-android
Resending of the messages missed in the subscription
- Dominant language
- Java
- Stars
- 106
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
Is it possible to configure the AppSync subscription mechanism to resend the messages missed due to the transport (internet connection) problems?
The use case:
1. The subscription is established using the `AWSAppSyncClient` configured with OIDC Auth provider.
2. Internet connection is lost for a while (wi-fi is turned off)
3. During this time some mutations A and B happen which must trigger the subscription
4. Internet connection is restored (wi-fi is turn on)
5. Mutations A and B never get delivered though
The code is
```kotlin
val sub: SubscribeToNewMessageSubscription = SubscribeToNewMessageSubscription.builder().conversationId(channelID).build()
val cb = object : AppSyncSubscriptionCall.Callback {
override fun onResponse(response: Response) {
Log.i("sub_test", "got response")
}
override fun onFailure(e: ApolloException) {
Log.e("sub_test", "got failure", e)
}
override fun onCompleted() {
Log.e("sub_test", "completed")
}
}
val client: AWSAppSyncClient = oidcAppSyncClient
client.subscribe(sub).execute(cb)
```
Logs
```
18:40:54.482 15859-15859 I/sub_test: [type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: , failover: false, available: true, roaming: false]
18:43:03.153 15859-19998 I/sub_test: got response
18:43:29.216 15859-15859 I/sub_test: [type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
18:43:29.253 15859-19998 E/sub_test: got failure
com.apollographql.apollo.exception.ApolloException: Subscription failed.
at com.amazonaws.mobileconnectors.appsync.WebSocketConnectionManager.notifyFailure(WebSocketConnectionManager.java:345)
at com.amazonaws.mobileconnectors.appsync.WebSocketConnectionManager.access$700(WebSocketConnectionManager.java:45)
at com.amazonaws.mobileconnectors.appsync.WebSocketConnectionManager$1.onFailure(WebSocketConnectionManager.java:169)
Caused by: java.net.SocketException: Software caused connection abort
18:43:29.509 15859-21248 E/sub_test: got failure ...
18:43:29.515 15859-21240 E/sub_test: got failure ...
18:43:30.010 15859-21251 E/sub_test: got failure ...
18:43:30.022 15859-21240 E/sub_test: got failure ...
18:43:30.889 15859-21252 E/sub_test: got failure ...
18:43:30.893 15859-21240 E/sub_test: got failure ...
18:43:32.607 15859-21260 E/sub_test: got failure ...
18:43:32.611 15859-21240 E/sub_test: got failure ...
18:43:35.868 15859-21268 E/sub_test: got failure ...
18:43:42.351 15859-21280 E/sub_test: got failure ...
18:43:55.283 15859-21296 E/sub_test: got failure ...
18:44:20.984 15859-21590 E/sub_test: got failure ...
HERE TWO NEW MUTATIONS WERE PRODUCED
2021-10-14 18:44:23.462 15859-15859/com.ehawk.repath.dev I/sub_test: [type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: , failover: false, available: true, roaming: false]
BUT THOSE 2 MUTATIONS WEREN'T RECEIVED AFTER CONNECTION RESTORE
```
**Environment**
AppSync SDK Version: 3.2.0
**Device Information:**
- Device: Samsung s21
- Android Version: 11
Contributor guide
Research direction
Start with WebSocketConnectionManager.java and the AWSAppSyncClient subscription entry point shown in the report. Trace what happens after the transport failure and when connectivity returns, then determine how missed subscription messages could be recovered. Done means the documented disconnect/reconnect scenario has a defined recovery behavior and appropriate coverage or a clearly reported limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, aws, graphql, kotlin
- Domain
- api, mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100