Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,16 @@ export class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink {
};
this.awsRealTimeSocket.onclose = event => {
logger(`WebSocket closed ${event.reason}`);
rej(new Error(JSON.stringify(event)));
// Error code 1000 means that the connection was closed normally.
if (event.code === 1000 || navigator.onLine) {
rej(new Error(JSON.stringify(event)));
} else {
logger("You are offline. Reconnecting once online");
// Initialize handshake once online again
window.addEventListener('online', () => {
this._initializeHandshake({ awsRealTimeUrl });
});
}
};

this.awsRealTimeSocket.onmessage = (message: MessageEvent) => {
Expand Down