-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(@aws-amplify/pubsub): Handle onclose events in AwsRealTimeSocket #6448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This change allows a user of the socket to restart the subscription after it terminates without an error. This can sometimes happen when devices enter or leave standby.
Codecov Report
@@ Coverage Diff @@
## main #6448 +/- ##
==========================================
- Coverage 73.31% 73.29% -0.02%
==========================================
Files 208 208
Lines 12922 12925 +3
Branches 2526 2526
==========================================
Hits 9474 9474
- Misses 3257 3260 +3
Partials 191 191
Continue to review full report at Codecov.
|
|
We're seeing the same behavior as described in #5403 and would love to see this merged! |
|
@greimela @bensie I was able to validate this (including @adamup928's example from #5403). Since a socket reconnect doesn't happen automatically, how are/would you handling reconnecting? |
ericclemmons
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR!
I confirmed I can pick up on the close event via the error method:
const subscription = API.graphql({
authMode: owner ? 'AMAZON_COGNITO_USER_POOLS' : 'AWS_IAM',
query: onUpdateAlbum,
variables: { owner },
}).subscribe({
error(error) {
console.log('Subscription error', error);
},
next(payload) {
setAlbum(payload.value.data.onUpdateAlbum);
},
});|
@ericclemmons Nice, thanks for the confirmation! We are using the error callback to restart our subscriptions. So if the close events arrive there it's perfect for us 👌 |
elorzafe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @greimela 🎉 🌮 🥇
This change allows a user of the socket to restart the subscription after it terminates without an error. This can sometimes happen when devices enter or leave standby. Co-authored-by: Eric Clemmons <[email protected]>
|
@greimela Would you mind sharing how you trigger the websocket reconnect from within the subscribe |
|
@bensie We are actually opening a completely new subscription in the case of an error. |
|
@greimela Guessing I'm missing a step here and I think we might be mixing up terminology - with 1 websocket connection and many subscriptions on that connection, if the websocket connection is closed and the |
|
@bensie We are using this lib only through the GraphQL subscriptions, so we might speak of different We just call |
|
@greimela Interesting, thanks! I'll keep digging, when we do that the websocket connection doesn't seem to reconnect automatically and the resubscribe fails. |
This change allows a user of the socket to restart the subscription after it terminates without an error. This can sometimes happen when devices enter or leave standby. Co-authored-by: Eric Clemmons <[email protected]>
|
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Issue #, if available:
#5403
Description of changes:
This change allows a user of the socket to restart the subscription after it terminates without an error.
This can sometimes happen when devices enter or leave standby.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.