Android Question Making errors in the MQTT_chat code always seems to go wrong in this line

cxdzbl

Active Member
Licensed User
Dim receivedObject As Object = serializator.ConvertBytesToObject(Payload)

B4X:
starter_client_messagearrived (java line: 283)
java.util.zip.ZipException: incorrect header check
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:170)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:122)
    at java.io.DataInputStream.readByte(DataInputStream.java:265)
    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.liveChat.starter._client_messagearrived(starter.java:283)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at anywheresoftware.b4a.BA$2.run(BA.java:360)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6646)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
*** Service (starter) Create ***
 

cxdzbl

Active Member
Licensed User
This means that the data sent was not serialized with B4XSerializator.
Although I know this is not a forum for JavaScript, I still want the great gods to help me, because it is related to b4a. Thank you
My data structures are: Type, Message (ID, As, String, name, As, String, userIMG (), As, file_type, As, Int, mess, As, String, value (), As, Byte, time, As, Byte,, String, bmpH, As, Int, bmpW, Int, As)
I am now using paho-mqtt.js to realize information exchange web and mobile phone, but could not be resolved at the web end of serializator.ConvertObjectToBytes () sending data, mobile phone terminal can parse the web data sending end.
 
Upvote 0

cxdzbl

Active Member
Licensed User
B4XSerializator will only be able to de-serialize objects serialized with B4XSerializator. You cannot use it with your JavaScript. You will need to serialize the data yourself.
Isn't JavaScript able to parse the b4a sent by bytes?
 
Upvote 0
Top