Skip to content
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

Occasionally mqtt cannot connect #5177

Closed
weidongliu opened this issue Jan 30, 2024 · 4 comments
Closed

Occasionally mqtt cannot connect #5177

weidongliu opened this issue Jan 30, 2024 · 4 comments
Labels
bug Something isn't working iot Issues related to the IoT SDK

Comments

@weidongliu
Copy link

Describe the bug
I have a problem that mqtt cannot connect successfully. The log shows that the most recent one is Websocket is created and opened. Occasionally

Environment(please complete the following information):

  • AWSAuthCore (2.33.0):
    • AWSCore (= 2.33.0)
    • AWSCognitoIdentityProvider (2.33.0):
      • AWSCognitoIdentityProviderASF (= 2.33.0)
      • AWSCore (= 2.33.0)
    • AWSCognitoIdentityProviderASF (2.33.0):
      • AWSCore (= 2.33.0)
    • AWSCore (2.33.0)
    • AWSIoT (2.33.0):
      • AWSCore (= 2.33.0)
    • AWSMobileClient (2.33.0):
      • AWSAuthCore (= 2.33.0)
      • AWSCognitoIdentityProvider (= 2.33.0)
      • AWSCognitoIdentityProviderASF (= 2.33.0)
      • AWSCore (= 2.33.0)

Device Information (please complete the following information):

  • Device: iphonex
  • iOS Version: iOS16

Logs

Please logs in the code block below. (See: Logs Guidance)

Log Messages
2024/01/30 10:54:30:066  ClockTick:752: nothing to republish
2024/01/30 10:54:31:066  ClockTick:753: nothing to republish
2024/01/30 10:54:32:066  ClockTick:754: nothing to republish
2024/01/30 10:54:33:066  ClockTick:755: nothing to republish
2024/01/30 10:54:34:066  ClockTick:756: nothing to republish
2024/01/30 10:54:35:069  ClockTick:757: nothing to republish
2024/01/30 10:54:36:069  ClockTick:758: nothing to republish
2024/01/30 10:54:37:069  ClockTick:759: nothing to republish
2024/01/30 10:54:38:069  ClockTick:760: nothing to republish
2024/01/30 10:54:39:069  ClockTick:761: nothing to republish
2024/01/30 10:54:40:069  ClockTick:762: nothing to republish
2024/01/30 10:54:40:160  Unsubscribing from topic TO_APP_MESSAGE_1751934295870689281
2024/01/30 10:54:40:160  messageId sending now 5
2024/01/30 10:54:40:160  <<<_NSMainThread: 0x2833144c0>{number = 1, name = main}>>: MQTTSession.send msg to server
2024/01/30 10:54:40:160  sending 40 bytes
2024/01/30 10:54:40:161  [SR] NSStreamEventHasSpaceAvailable <__NSCFOutputStream: 0x2814072a0>
2024/01/30 10:54:40:161  <<<NSThread: 0x2833a8900>{number = 78, name = (null)}>>: MQTTSession.send msg to server
2024/01/30 10:54:40:161  sending 2 bytes
2024/01/30 10:54:40:161  AWSIoTMQTTClient: Disconnect message issued.
2024/01/30 10:54:40:161  [SR] NSStreamEventHasSpaceAvailable <__NSCFOutputStream: 0x2814072a0>
2024/01/30 10:54:40:498  [SR] NSStreamEventHasBytesAvailable <__NSCFInputStream: 0x281407210>
2024/01/30 10:54:40:498  [SR] Received message
2024/01/30 10:54:40:499  [SR] using _delegateDispatchQueue.
2024/01/30 10:54:40:499  Websocket didReceiveMessage: Received 4 bytes
2024/01/30 10:54:40:499  closing encoder stream.
2024/01/30 10:54:40:499  closing decoder stream.
2024/01/30 10:54:40:500  [SR] Closing with code 1000 reason (null)
2024/01/30 10:54:40:500  [SR] NSStreamEventHasSpaceAvailable <__NSCFOutputStream: 0x2814072a0>
2024/01/30 10:54:40:884  [SR] NSStreamEventHasBytesAvailable <__NSCFInputStream: 0x281407210>
2024/01/30 10:54:40:884  [SR] Received close frame
2024/01/30 10:54:40:884  [SR] NSStreamEventHasBytesAvailable <__NSCFInputStream: 0x281407210>
2024/01/30 10:54:40:885  [SR] NSStreamEventEndEncountered <__NSCFInputStream: 0x281407210>
2024/01/30 10:54:40:885  [SR] Trying to disconnect
2024/01/30 10:54:40:885  [SR] using _delegateDispatchQueue.
2024/01/30 10:54:40:885  WebSocket closed with code:1005 with reason:(null)
2024/01/30 10:55:17:974  Retrieving credentials from keychain
2024/01/30 10:55:17:982  Initializing AWSIoTMqttConfiguration with KeepAlive:300.000000, baseReconnectTime:1.000000,minimumConnectionTime:20.000000, maximumReconnectTime:128.000000, autoResubscribe:Enabled, lwt topic: message: 
2024/01/30 10:55:18:188  IOTDataManager: Connecting to IoT using websocket, client id: BE0D4712-E8E9-4FFB-B591-345BBE598AD5
2024/01/30 10:55:18:188  AWSIoTMQTTClient: connecting via websocket. 
2024/01/30 10:55:18:188  Using AWSCredentials.
2024/01/30 10:55:18:189  user metadata is : ?SDK=iOS&Version=2.33.0
2024/01/30 10:55:18:189  Metrics collection is: Enabled
2024/01/30 10:55:18:189  -[AWSMQTTSession initWithClientId:userName:password:keepAlive:cleanSession:willTopic:willMsg:willQoS:willRetainFlag:publishRetryThrottle:] [Line 84], Thread:<_NSMainThread: 0x2833144c0>{number = 1, name = main} 
2024/01/30 10:55:18:189  +[AWSMQTTMessage connectMessageWithClientId:userName:password:keepAlive:cleanSession:willTopic:willMsg:willQoS:willRetain:] [Line 66], Thread:<_NSMainThread: 0x2833144c0>{number = 1, name = main} 
2024/01/30 10:55:18:189  Creating AWSMQTTMessage with raw data >>>>> {length = 73, bytes = 0x00044d51 54540482 012c0024 42453044 ... 6e3d322e 33332e30 } <<<<<
2024/01/30 10:55:18:190  Websocket is created and opened.

@5d 5d added bug Something isn't working iot Issues related to the IoT SDK labels Jan 30, 2024
@thisisabhash
Copy link
Member

thisisabhash commented Feb 1, 2024

Hello, Thank you for posting this. Can you share code snippets and reproduction steps so that we can try reproducing this issue in our local environment?

@weidongliu
Copy link
Author

log.txt
The exception occurred on 2024/01/29 at 18:35. We have encountered it a few times, and it happens occasionally after the app has been in use for some time and the phone is locked. After a period of time, when the phone is unlocked again, the exception occurs. Since it happens sporadically, I am unable to reproduce it. Based on the logs, I observed that the exception is triggered after the message "Websocket is created and opened" is logged, but there is no subsequent log entry of "[SR] NSStreamEventOpenCompleted". @thisisabhash
image

@lawmicha
Copy link
Contributor

Hello, we released 2.33.9 which includes an IoT crash fix #5185. Please upgrade to this and let us know if you are still experiencing the issue.

@sebaland
Copy link
Member

sebaland commented Apr 3, 2024

Closing due to inactivity. Please reopen if this is still an issue.

@sebaland sebaland closed this as completed Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working iot Issues related to the IoT SDK
Projects
None yet
Development

No branches or pull requests

5 participants