awslabs / awslabs/aws-mobile-appsync-sdk-android

onFailure() not called when WebSocket connection fails

Open
#272 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
106
Forks
56
PR merge metrics
No merged PRs in 30d

Description

**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**
* Start the app without connectivity
* First subscription is created
* WebSocket connection gets created
* WebSocket connection fails and calls ``notifyFailure()``

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**

* Start the app with connectivity
* Subscription is created
* WebSocket connection is created
* Switch airplane mode on
* WebSocket connection fails and calls ``notifyFailure()``
* ``onFailure()`` callbacks are properly called
* Switch airplane mode off
* Retry the subscription

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):**
- AppSync SDK Version: 3.0.1

**Device Information (please complete the following information):**
- Device: Simulator
- Android Version: 10

**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?

Contributor guide

Open the contributing guide

Research direction

Start in WebSocketConnectionManager and trace notifyFailure() against the subscriptions Map for both connection-failure scenarios described. Reproduce an initial failure and a retry after connectivity returns, then verify that onFailure() is called whenever the subscription has not been successfully created and that subsequent subscriptions do not remain silently queued after the WebSocket is lost.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, graphql, java
Domain
api, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.