awslabs / aws-mobile-appsync-sdk-android

Android SDK for AWS AppSync.
https://docs.amplify.aws/sdk/api/graphql/q/platform/android/
Apache License 2.0
105 stars 58 forks source link

onFailure() not called when WebSocket connection fails #272

Open xvarlez opened 4 years ago

xvarlez commented 4 years ago

Describe the bug

Hi,

I am having trouble using the subscriptions. It looks like when there is a network failure and the WebSocket connection gets lost, the subsequent subscriptions will just fail silently (onFailure() doesn't get called).

To Reproduce

Scenario 1

In this scenario, my onFailure() callback never gets called. From looking in WebSocketConnectionManager, it looks like you're trying to call it too soon, when my subscription has not yet been added to the subscriptions Map.

Scenario 2

Here again, onFailure() doesn’t get called. So you think the subscription has been successfully created, however it has not and I am not receiving any data on it.

Expected behavior onFailure() should get called if the subscription has not been successfully created

Environment(please complete the following information):

Device Information (please complete the following information):

Additional context

Looking at the WebSocketConnectionManager class it looks like you never try to reestablish the WebSocket connection in case of failure. The subsequent calls are just queued despite the connection being lost. I believe the connection should be closed and reattempted in case of failure?

jamesonwilliams commented 4 years ago

Hi @xvarlez - thanks for the report. I believe this report is accurate. Amplify Android contains WebSocket subscription code, as well. And I recall that we added support for connection_error type messages, in it. But, this AppSync code base may not have received the same update, yet.

xvarlez commented 4 years ago

HI @jamesonwilliams

Thanks for your reply. Are there any plans to update the AppSync SDK soon with those changes?