-
Notifications
You must be signed in to change notification settings - Fork 880
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
IoT connection issues on packet loss. #1002
Comments
Thank you for reporting this issue. I will investigate and get back to you.
|
@cbommas After further investigation i have discovered that the fist issue happens because default KeepAliveInterval is set to 300, so it can take up to 5 minutes before the stream is closed, this can be avoided if keepAlive is reduced to detect a packet loss earlier. So this was basically an issue of me being impatient and the SDK not noticing that there is packet loss, so i have reduced the keepAlive in our app to 30 for it to catch the packet loss earlier. If the connection is restored within that time it reconnects automatically otherwise the stream is being terminated. Don't know if there is a better way or if the SDK can do a ping to check if there is a connection. The second issue happens when the keepAlive runs out and it closes the stream but mqttStatus is still connected in case MQTTSessionEventConnectionClosed: But i have fixed it by adding these 2 lines in the switch case.
so the switch case ends up looking like this:
if those 2 lines are missing then initiateReconnectTimer wont run because mqttStatus is still connected, i don't know if this breaks something else without having further knowledge of the SDK. |
@cbommas any news |
Thank you @steelzeh for your analysis. I was able to confirm this behavior and test out the fix. This is an edgecase of the fix we made for #965. The fix will be included in the next rev of the SDK (the timing is currently TBD, I will post back here once I have a timeline). I made a small change to your suggested fix. The Switch now looks like this
It will be great if you can give it a go on your side and let me know if you run into issues. |
Alright thank you @cbommas |
@cbommas we were running our own forked version as we didn't want to wait 10 days for the update to be rolled out. But it seems to have fixed our issues. |
Thank you for confirming. I will go ahead and close this issue. Please reopen if you encounter further issues. |
What service are you using?
IoT
In what version of SDK are you facing the problem?
2.6.25
Is the issue limited to Simulators / Actual Devices?
Only tested on actual device
Can your problem be resolved if you bump to a higher version of SDK?
No
Is this problem related to specific iOS version?
No
How are you consuming the SDK? CocoaPods / Carthage / Prebuilt frameworks?
Carthage
Can you give us steps to reproduce with a minimal, complete, and verifiable example? Please include any specific network conditions that might be required to reproduce the problem.
After the connection to a socket has been established, if there is a packet loss for an extended period of time the MQTT session is closed without notifying the user, this results in a disconnected socket where the status of the socket is still connected.
MQTTSessionEventConnectionClosed: MQTT session closed.
If you try and fetch .getConnectionStatus now it will return 2 = connected.
Nothing is notifying the user, the connection just gets terminated.
In another case the SDK never realises that the connection is lost, and when you disable the Network Link Conditioner no data comes through the socket.
So sometimes the sdk continues to say ClockTickXXX for an unknown time and the stream is never closed, other times after an extended period of time the stream is closed and the reconnectTimer is never initialised because in initiateReconnectTimer it checks if the mqttStatus != connected, but mqttStatus is never set to anything other than connected in MQTTSessionEventConnectionClosed siwtch case unless userDidIssueDisconnect is true.
@cbommas
The text was updated successfully, but these errors were encountered: