aws-mobile-appsync-sdk-android
aws-mobile-appsync-sdk-android copied to clipboard
Subscription initialization throws "Invalid message type string" exception when token has expired
Describe the bug
The issue happens when app tries to initialize subscription with an expired token.
WebSocketConnectionManager.processJsonMessag(websocket, message)
gets as message:
{"type":"connection_error","payload":{"errors":[{"errorType":"Unauthorized","errorCode":401}]}}
which cannot be parsed because connection_error does not exists in MessageType enum.
So the result is IllegalArgumentException("Invalid message type string");
To Reproduce Steps to reproduce the behavior: Provide expired token during subscription initialization.
Expected behavior
New MessageType suitable to code 401 should be added so IllegalArgumentException("Invalid message type string");
won't be thrown. And subscription request should be repeated with the refreshed token.
Environment(please complete the following information):
- AppSync SDK Version: 3.0.1
Device Information (please complete the following information):
- Samsung Galaxy S7 edge
- Android Version: 8.0.0
@JakubGongol Thanks for reporting this. I will look into it and provide an update.
Hi @desokroshan any update about this issue, please?
Hi @JakubGongol - we would like to fix this issue, but don't have a fix date for it, yet.
We have code for realtime subscriptions in two code bases: this production AppSync SDK, and our in-development Amplify Android project. I believe we are correctly handling the "connection_error"
message type in the new code base.
We would like to have this functionality into the AppSync SDK, too. To fix this, some changes are needed in the WebSocketConnectionManager
. Would certainly review a PR, if one comes in before we can fix this.