iOS Question My App Crash MQTT Disconnected

tzfpg

Active Member
Licensed User
Longtime User
Hi,

I have facing this problem when release IOS app.

Unexpected event (missing RaisesSynchronousEvents): client_disconnected

B4X:
MQTTSessionManager connecting
Unexpected event (missing RaisesSynchronousEvents): client_disconnected
MQTTSessionManager connecting
Error occurred on line: 546 (Main)
Method not found: resumeAsUserSub, target: <b4i_main: (null)>
Stack Trace: (
  CoreFoundation       DA838E75-6B30-360E-9661-C4800A7E1BF6 + 1227168
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       DA838E75-6B30-360E-9661-C4800A7E1BF6 + 135252
  LDM Lite             +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 388
  LDM Lite             -[B4IShell runGoodChain::] + 348
  LDM Lite             -[B4IShell raiseEventImpl:method:args::] + 2408
  LDM Lite             -[B4IShellBI raiseEvent:event:params:] + 1580
  LDM Lite             -[B4IDelegatableResumableSub resume::] + 380
  LDM Lite             -[B4I checkAndRunWaitForEvent:event:params:] + 552
  LDM Lite             -[B4IShellBI raiseEvent:event:params:] + 1436
 LDM Lite             +[B4IObjectWrapper raiseEvent:::] + 300
 LDM Lite             -[MQTTClient observeValueForKeyPath:ofObject:change:context:] + 196
 Foundation           0DF2911E-80CB-3289-8A1E-ED0913D55A12 + 1026600
 Foundation           0DF2911E-80CB-3289-8A1E-ED0913D55A12 + 1034884
 Foundation           0DF2911E-80CB-3289-8A1E-ED0913D55A12 + 1033432
 Foundation           0DF2911E-80CB-3289-8A1E-ED0913D55A12 + 310716
 Foundation           0DF2911E-80CB-3289-8A1E-ED0913D55A12 + 1014548
 LDM Lite             -[MQTTSessionManager handleEvent:event:error:] + 468
 LDM Lite             -[MQTTSession decoder:newMessage:] + 1460
 LDM Lite             -[MQTTDecoder stream:handleEvent:] + 2260
 CoreFoundation       DA838E75-6B30-360E-9661-C4800A7E1BF6 + 793400
 CoreFoundation       DA838E75-6B30-360E-9661-C4800A7E1BF6 + 781076
 CoreFoundation       DA838E75-6B30-360E-9661-C4800A7E1BF6 + 780492
 CFNetwork            _CFStreamErrorFromCFError + 135904
 CFNetwork            _CFStreamErrorFromCFError + 163292
 CoreFoundation       DA838E75-6B30-360E-9661-C4800A7E1BF6 + 742844
 CoreFoundation       DA838E75-6B30-360E-9661-C4800A7E1BF6 + 694240
 CoreFoundation       DA838E75-6B30-360E-9661-C4800A7E1BF6 + 694072
 CoreFoundation       DA838E75-6B30-360E-9661-C4800A7E1BF6 + 692000
 CoreFoundation       DA838E75-6B30-360E-9661-C4800A7E1BF6 + 671772
 CoreFoundation       CFRunLoopRunSpecific + 464
 GraphicsServices     GSEventRunModal + 104
 UIKitCore            UIApplicationMain + 1936
 LDM Lite             main + 124
 libdyld.dylib        E1637502-BFCB-3BBC-B3E1-CCF78617E0E4 + 5216
)

and my code

B4X:
Sub ConnectAndReconnect
    Do While working
        If client.IsInitialized Then client.Close
        client.Initialize("client", $"tcp://${mqttIP}:${mqttPort}"$, ClientName)
        Dim mo As MqttConnectOptions
        mo.Initialize(mqttuser, mqttpassword)
        #If D
            Log("Trying to connect.")
        #End If
        
        client.Connect2(mo)
        Wait For client_Connected (Success As Boolean)
        If Success Then
            #If D
                Log("Mqtt connected.")
            #End If
            mqttConnect=Success
            Do While working And client.Connected
                client.Publish2("ping",Ser.ConvertObjectToBytes(0), 1, False) 'change the ping topic as needed
                Sleep(5000)
            Loop
            #If D
                Log("Disconnected.")
            #End If
            mqttConnect=False
        Else
            #If D
                Log("Error connecting: " & LastException)
            #End If
            mqttConnect=False
        End If
        Sleep(5000)
    Loop
End Sub

Private Sub client_disconnected
    #If D
        Log("Disconnected")
    #End If
    mqttConnect=False
End Sub

Thank you for help
 
Top