Subscriptions do not throw error on websocket failure
See original GitHub issueDescribe the bug
When subscribing to AppSync updates through AWS Amplify, undefined
websocket errors do not invoke the error
callback. If a websocket is unable to connect and returns undefined
, an error is logged in the console but the subscription’s error callback is not invoked.
To Reproduce This occurs when the webapp is connected to a network that blocks or inhibits websocket connections, such as some proxies and corporate networks.
Expected behavior
When an error occurs such as a network disconnection, the error
callback should be invoked. Currently a network disconnection invokes the error
callback but an undefined
websocket connection does not.
Desktop:
- OS: Windows 7, Windows 10, and MacOS X
- Browser: Chrome 73, IE 11, and Edge 15
Smartphone:
- Device: iPhone X
- OS: iOS 12.2
- Browser: Safari
Sample code
API.graphql(
graphqlOperation(subscriptions.mutatedItem, { item_id: item_id })
).subscribe({
error: (err) => console.log("Network disconnected"),
next: (eventData) => updateItems(eventData)
});
Console Output
paho-mqtt.js:1128 WebSocket connection to ‘wss://**************-ats.iot.us-west-2.amazonaws.com/mqtt?..’ failed: Error during WebSocket handshake: Unexpected response code: 400 S._doConnect @ paho-mqtt.js:1128
Uncaught (in promise) Object errorCode: 7 errorMessage: “AMQJS0007E Socket error:undefined.” invocationContext: undefined
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (1 by maintainers)
Top GitHub Comments
Any update on this? I always get this error when trying to subscribe to a topic after internet is restored.
I let my application run for sometime and I watched messages console. Then I reloaded my web browser and I got this:
I did not get the undefined socket error and the application still shows messages from the topic. It looks like the reconnection is happening internally. I wonder if it could useful that MqttOverWSProvider informs about any reconnection issue to the user?. Thanks.