Hello,
I am getting error while subscribing the message from MQTT Broker. Whereas it is working fine while publish the meaasge
I am getting the below error
The below is the code for MQTT subscribe
Please advice
I am getting error while subscribing the message from MQTT Broker. Whereas it is working fine while publish the meaasge
I am getting the below error
B4X:
main_mqtt_messagearrived (java line: 461)
java.util.zip.ZipException: incorrect header check
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:175)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:127)
at java.io.DataInputStream.readByte(DataInputStream.java:268)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readByte(B4XSerializator.java:133)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:301)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:112)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertBytesToObject(B4XSerializator.java:82)
at b4a.example.main._mqtt_messagearrived(main.java:461)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6820)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
java.util.zip.ZipException: incorrect header check
The below is the code for MQTT subscribe
B4X:
Sub mqtt_Connected (Success As Boolean)
If Success = False Then
Log(LastException)
lblStatus.Text = "Error connecting"
Else
lblStatus.Text = "Connected"
mqtt.Subscribe("outTopic", 0)
End If
End Sub
Private Sub mqtt_Disconnected
lblStatus.Text = "Disconnected"
End Sub
Private Sub mqtt_MessageArrived (Topic As String, Payload() As Byte)
Dim obj As Object = serializator.ConvertBytesToObject(Payload)
If obj Is CircleData Then
If Topic = mytopic Then Return 'the circle was already drawn
Dim cd As CircleData = obj
DrawCircleData(cd)
Else 'obj is string
Dim s As String = obj
Select s
Case "clear"
Canvas1.DrawColor(Colors.Black)
Activity.Invalidate
Case "close"
Activity.Finish
End Select
End If
End Sub
Please advice