-
Notifications
You must be signed in to change notification settings - Fork 132
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
SubscriptionStatusObserver is not working #393
Comments
Hi @vishaldroisys I am trying to create a test project and replicate what you are seeing.
Thank you! |
Hi @wooj2 Thanks for the reply. User will start or stop their internet through enable or disable their WIFI connection. in other terms user will go from online to offline or offline to online. Thanks. |
Hi @vishaldroisys , Thank you for your patience. I am not super familiar with this codebase, but I was able to reproduce this is issue you are seeing. When executing code, and turning off wifi, the In looking how the code works,
And attempts to reconnect the websocket connection rather than just returning a disconnected state. If you wait long enough, the code no longer retries to connect the websocket and the It seems that the code should be updated so that the statusChangeHandler is executed with a .disconnected state while the connection attempts to be re-established. Is this correct? |
Hi @wooj2 Yes it is. It will resolved in next version of Appsync framework right?? Thanks. |
@vishaldroisys If this is a new feature in your project (or you can afford to migrate), we highly recommend you adopt Amplify Datastore as it's responsibility is to handle the complex task of synchronization to the cloud, as well as providing a powerful interface to query & mutate your data. If you'd like to learn more about data store, you check out this video: And visit our official documentation here: |
Hello, please try to understand. we don't want to use Amplify Framework right now. please tell us. Is this feasible/possible through Appsyncclient framework or not. Thanks. |
Hi @vishaldroisys, I looked into the code and I believe that The behavior of unsubscribe() is documented here: To see this in code, if we look to see when Despite the above description being the expected behavior, if you call
Taking a step back, if you are interested in getting status on the state of your network status, you could use
Your class must conform to the protocol:
Finally, you will need to implement the following function to get updates on the network status:
Note that this solution does not hit support cases where your network connection is up, but the connection is unstable for one reason or another. For example, if you are connected to wifi, but your DNS is not working, I would not expect that Hope this helps, and best of luck. |
@wooj2 I tried ConnectionStateChangeHandler but that will return when user goes offline. but that will not call when user come back from offline to online. Thanks. |
Hi @vishaldroisys
Console Output:
Are you seeing something different? |
Hello @wooj2 iOS code
`` func subscribeForUpdateData() {
` My Console 2020-06-25 17:59:52.038993+0530 AppSync_POC[17510:1079148] Start subscription ******* After last log we are connecting wifi but unable to get event "Connected" event |
In looking at your code, it looks like you are correctly adding "connectionStateChangeHandler: self", but may have forgot to implement the required function
Also note that in your code you have added some cases for the |
@wooj2 func stateChanged(networkState: ClientNetworkAccessState) { please see console log. second last row in my console log: FYI: i have implemented method that you suggest. |
Hmm sounds like you've implemented the If this is the case, and I am understanding you correctly then, I am unable to reproduce this, and unable to make forward progress at this point. In all of my testing, when my device goes from having wifi turned off to wifi being turned on, the
Is there anything unique about your wifi network, or anything unique to your configuration? |
Yes you are right. Let me repeat my use case. I started my app with wifi connection. that time "State changed to: Online" is not called. then after i disconnect my wifi so in console there is printed "State changed to: Offline" then after i connected my wifi. there is not printed/called any event. Thanks |
I started my app with wifi connection. that time "State changed to: Online" is not called."
then after i disconnect my wifi so in console there is printed "State changed to: Offline"
then after i connected my wifi. there is not printed/called any event.
|
SHould I share Code file?? |
Hi @vishaldroisys, You can share your code, and I'd be happy to take a look, but I'm convinced that the code that you and I have are equivalent based on your logs and the code snippets that we've shared back and forth. At this point, I'm convinced that there is something specific to the device, network, or configuration that is out of our control. I'm not sure if this helps but, to be even more detailed about the steps I'm taking in this post: I have an iPhone 7 with iOS 13.3, without a cell network.
In taking a step back, maybe you can take a look at the code that is emitting the reachability status, and try debugging this on your side. Reachability notifications are sent via the NotificationCenter, with a name of aws-mobile-appsync-sdk-ios/AWSAppSyncClient/Internal/NetworkReachabilityNotifier.swift Line 150 in c4a062c
These notifications are received here:
Is there anything in the code links above that you can see that might prevent you from getting a Hope this helps, and best of luck. |
Hi @wooj2 Let me share my code. I have Attached my AppDelegate and My schema file. https://drive.google.com/file/d/1T9epWgvdtZhbO9PhhMd7BUdK2lRt6yjm/view?usp=sharing Thanks. |
|
Hi @wooj2 Have you tested my code?? Thanks |
i have shared my code and schema file. |
I looked at your code, and when you are instantiating
To get connection status updates, you will need to:
|
Hello, Can you please look into my code?? still not working for me. Thanks |
Hi @vishaldroisys, Thank you for posting an update of your code. I copy and pasted the relevant pieces of your application delegate into my project, and I am unable to reproduce the behavior you are seeing: When I turn wifi off of my device (which does not have a cell/LTE/data connection), I see the following print out:
When I turn wifi on, i see the following print out:
I am not sure why you are unable to get reachability status given that I have verified that your code has the following 3 items required:
At this point, we believe that there is some configuration, device, or network specific difference between our development environments, and unfortunately, we are unable to make forward progress at this time. If this is an important issue, you may want to try debugging this issue on your own given the guidance above: #393 (comment) Best of luck. |
Hello, We have implemented same. can you please look into code that i shared last. Thanks |
Hello, I have attaching my app video. please have to see that. Thanks. |
Hi @vishaldroisys, I noticed from the video you are teathered to your phone in the video. I suspect that the iPhone simulator process is not detecting that a connection has been re-connected. Can you try this on a physical device instead of using the simulator? |
Hi @vishaldroisys , Have you fix this issue? I am facing this error.
|
@abhishekjangid10 Please take a look at #396, it sounds like you're hitting that condition. @vishaldroisys We are going to close this issue for now. If you are able to repro with a physical device rather than a tethered one, please feel free to reopen and provide more info. |
@palpatim Thanks for the update. Its seems similar issue but different case. |
Describe the bug
I implemented SubscriptionStatusObserver with Subscribe method of AppsyncClient.
this is working SubscriptionStatusObserver state as "Connecting" and "Connected" State when app launch. and after that we disconnected the internect but SubscriptionStatusObserver is not returning state as "disconnected"
To Reproduce
Steps to reproduce the behavior:
Started App and initialize subscription through below code
let subscription = OnInsertUpdateAccountSubscription() do { subscriptionUpdateWatcher = try appSyncClient?.subscribe(subscription: subscription, queue: .main, statusChangeHandler: { (SubscriptionStatusObserver) in print(SubscriptionStatusObserver) }, resultHandler: { (result, transaction, error) in }) } catch { print("Error starting subscription: \(error.localizedDescription)") }
first Connecting... and then Connected the subscription
Stop Internet connection
SubscriptionStatusObserver as Disconnected not called.
Wait for 10-15 min
Started internet connection.
and i seen xcode console, following logs are display:
2020-06-10 17:55:20.277080+0530 AppSync_POC[10181:315548] WebsocketDidConnect 2020-06-10 17:55:20.277203+0530 AppSync_POC[10181:315548] WebsocketDidConnect, sending init message... 2020-06-10 17:55:20.277347+0530 AppSync_POC[10181:315548] Validating connection 2020-06-10 17:55:20.277444+0530 AppSync_POC[10181:315826] Message type does not need signing - connectionInit("connection_init") 2020-06-10 17:55:20.277597+0530 AppSync_POC[10181:315826] Websocket write - {"type":"connection_init"} 2020-06-10 17:55:20.278622+0530 AppSync_POC[10181:311394] Realtime connection is stale, disconnected. 2020-06-10 17:55:20.282033+0530 AppSync_POC[10181:311394] The operation couldn’t be completed. (AppSyncRealTimeClient.ConnectionProviderError error 3.) error(AWSAppSync.AWSAppSyncSubscriptionError.other(AppSyncRealTimeClient.ConnectionProviderError.connection))
Expected behavior
It should display "Connect" as Observer state. and we need handler to handle the each and every event
Environment(please complete the following information):
Device Information (please complete the following information):
Thanks in advanced.
The text was updated successfully, but these errors were encountered: