Android Question MQTT ZipException:incorrect header check error

JOHN NG

Member
Licensed User
Longtime User
Hi

This is my code to receive message arrive of MQTT . But i getting java.util.zip.ZipException:incorrect header check error at line : ConvertBytesToObject . The reply message is "true" , "false"

Private Sub mqtt_MessageArrived (Topic As String, Payload() As Byte)
Dim obj As Object = serializator.ConvertBytesToObject(Payload)


If obj Is String Then
Dim s As String = obj
Select s
Case "false"
Msgbox("Fail to turn off ","Message")
Case "true"
Msgbox("Success turn off ","Message")
End Select
End If

End Sub
 

JOHN NG

Member
Licensed User
Longtime User
Hi @Erel

This is my code to send MQTT . MQTT broker and client able to receive the message . But B4a can't receive the reply .

B4X:
Private serverURI As String = "tcp://111.111.111.111:1111"
  
   If mqtt.Connected == False Then
       Log("Client not connected")
       mqtt.Initialize("mqtt", serverURI, Rnd(0, 999999999) & DateTime.Now)
       Dim mo As MqttConnectOptions
       mo.Initialize("", "")
       mqtt.Connect2(mo)
       Log("Client connected")
   End If

   If mqtt.Connected == True Then
      mqtt.Subscribe("/Testing/Reply", 0)
       mqtt.Publish2("/Testing/123",Array As Byte(0),mqtt.QOS_2_EXACTLY_ONCE,False)
   'mqtt.Close
   End If
 
Upvote 0

OliverA

Expert
Licensed User
Upvote 0
Top