aws-amplify / aws-sdk-ios

AWS SDK for iOS. For more information, see our web site:
https://aws-amplify.github.io/docs
Other
1.68k stars 884 forks source link

AWS IOT mqtt connection over websockets not reconnecting #593

Closed ramki982 closed 7 years ago

ramki982 commented 7 years ago

In the last couple of days - we are seeing that the MQTT connection over websocket to AWS IOT is getting disconnected quite often and doesn't reconnect automatically.

By setting break points in the SDK code - I'm able to see that AWSSRWebsocket is receiving a stream end from server and following line in SDK code is triggered. [self.delegate webSocket:self didCloseWithCode:AWSSRStatusCodeGoingAway reason:@"Stream end encountered" wasClean:NO];

The code AWSSRStatusCodeGoingAway has value 1001. As per the RFC 6455 - this should occur only if the server is down or in case of browser, if the user moves away from the page.

Also in the AWSIoTMQTTClient.m - above error is causing the - (void)session:(MQTTSession*)session handleEvent:(MQTTSessionEvent)eventCode to be invoked with event code - MQTTSessionEventConnectionClosed.

There is a reconnect timer in the mqtt client - But the reconnectToSession is not getting triggered.

If I explicitly connect back - it is getting connected for few more seconds.

Could this be a server side issue because the code on iOS app is almost 3-4 months old and this has been happening over last few days?

thanks Ram

fengsongAWS commented 7 years ago

Hi @ramki982 , I saw your PR from here https://github.com/aws/aws-sdk-ios/pull/601. What you propose is correct. We are working on fix this and will release it in the future. Thanks

karthiksaligrama commented 7 years ago

fixed with 2.5.2