marcel Active Member Licensed User Longtime User Feb 27, 2016 #1 Hi, I am trying to use MQTT for a project. I am playing arround a little bit. I am using on the Windows side: https://m2mqtt.wordpress.com/ using vb.net. I implemented the broker and a client. This works all ok. Now I try to connect the client for android. I use the sample of post https://www.b4x.com/android/forum/threads/b4x-mqtt-chat-room.61568/ Connection goes well. But when I post a message to a subject I get an error in the Andriod app: Code: Private Sub client_MessageArrived (Topic As String, Payload() As Byte) Dim receivedObject As Object = serializator.ConvertBytesToObject(Payload) add ConvertBytes Code: Connected: true Error occurred on line: 60 (Starter) java.io.IOException at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:177) at libcore.io.Streams.readSingleByte(Streams.java:41) at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:130) at java.io.DataInputStream.readByte(DataInputStream.java:75) at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readByte(B4XSerializator.java:131) at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:299) at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:110) at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertBytesToObject(B4XSerializator.java:81) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:702) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:336) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134) at anywheresoftware.b4a.BA$2.run(BA.java:328) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5832) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) Caused by: java.util.zip.DataFormatException: incorrect header check at java.util.zip.Inflater.inflateImpl(Native Method) at java.util.zip.Inflater.inflate(Inflater.java:237) at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) ... 24 more In vb dotnet I post the message using: Code: pclient.Publish("/all/1", Encoding.UTF8.GetBytes(strValue), Messages.MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, False) Does this mean: 1) Is MQTT not compatible, which I do not think so 2) Is the problem converting to bytes? Do I need to convert differently on the dotnet side? Or is the conversion on the android site wrong? I am kind of lost here.
Hi, I am trying to use MQTT for a project. I am playing arround a little bit. I am using on the Windows side: https://m2mqtt.wordpress.com/ using vb.net. I implemented the broker and a client. This works all ok. Now I try to connect the client for android. I use the sample of post https://www.b4x.com/android/forum/threads/b4x-mqtt-chat-room.61568/ Connection goes well. But when I post a message to a subject I get an error in the Andriod app: Code: Private Sub client_MessageArrived (Topic As String, Payload() As Byte) Dim receivedObject As Object = serializator.ConvertBytesToObject(Payload) add ConvertBytes Code: Connected: true Error occurred on line: 60 (Starter) java.io.IOException at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:177) at libcore.io.Streams.readSingleByte(Streams.java:41) at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:130) at java.io.DataInputStream.readByte(DataInputStream.java:75) at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readByte(B4XSerializator.java:131) at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:299) at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:110) at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertBytesToObject(B4XSerializator.java:81) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:702) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:336) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134) at anywheresoftware.b4a.BA$2.run(BA.java:328) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5832) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) Caused by: java.util.zip.DataFormatException: incorrect header check at java.util.zip.Inflater.inflateImpl(Native Method) at java.util.zip.Inflater.inflate(Inflater.java:237) at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) ... 24 more In vb dotnet I post the message using: Code: pclient.Publish("/all/1", Encoding.UTF8.GetBytes(strValue), Messages.MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, False) Does this mean: 1) Is MQTT not compatible, which I do not think so 2) Is the problem converting to bytes? Do I need to convert differently on the dotnet side? Or is the conversion on the android site wrong? I am kind of lost here.
R rboeck Well-Known Member Licensed User Longtime User Feb 27, 2016 #2 Hi, currently i am working with mqtt, but only with b4a and b4j. If your app is calling mqtt_client_MessageArrived then you transfer data between the systems and why should there be an compatibilty problem? For the second question look at: https://www.b4x.com/android/forum/threads/send-string-text-from-b4a-into-vb-net.39025/#post-232131 Which vb.net client are you using? I also want to combine different tools and i am searching for solutions. Greetings from austria Upvote 0
Hi, currently i am working with mqtt, but only with b4a and b4j. If your app is calling mqtt_client_MessageArrived then you transfer data between the systems and why should there be an compatibilty problem? For the second question look at: https://www.b4x.com/android/forum/threads/send-string-text-from-b4a-into-vb-net.39025/#post-232131 Which vb.net client are you using? I also want to combine different tools and i am searching for solutions. Greetings from austria
Erel B4X founder Staff member Licensed User Longtime User Feb 28, 2016 #3 Why are you using VB.Net instead of B4J? B4XSerializator will only work with B4X tools. Upvote 0
marcel Active Member Licensed User Longtime User Feb 28, 2016 #4 Erel said: Why are you using VB.Net instead of B4J? Click to expand... Client would like to have the server site in dotnet and no java. They would also prefer some back office clients in native window. Basically it should be compatible... Does this mean the conversion from the byte array goes wrong? Upvote 0
Erel said: Why are you using VB.Net instead of B4J? Click to expand... Client would like to have the server site in dotnet and no java. They would also prefer some back office clients in native window. Basically it should be compatible... Does this mean the conversion from the byte array goes wrong?
marcel Active Member Licensed User Longtime User Feb 28, 2016 #5 rboeck said: Hi, Which vb.net client are you using? I also want to combine different tools and i am searching for solutions. Click to expand... https://m2mqtt.wordpress.com/ Upvote 0
rboeck said: Hi, Which vb.net client are you using? I also want to combine different tools and i am searching for solutions. Click to expand... https://m2mqtt.wordpress.com/
Erel B4X founder Staff member Licensed User Longtime User Feb 28, 2016 #6 marcel said: Does this mean the conversion from the byte array goes wrong? Click to expand... You can use MQTT. However you cannot use B4XSerializator. Check the code and you will see that it uses B4XSerializator. Note that Java doesn't need to be installed on the server. You can include the files together with your server files. Upvote 0
marcel said: Does this mean the conversion from the byte array goes wrong? Click to expand... You can use MQTT. However you cannot use B4XSerializator. Check the code and you will see that it uses B4XSerializator. Note that Java doesn't need to be installed on the server. You can include the files together with your server files.
marcel Active Member Licensed User Longtime User Feb 28, 2016 #7 Erel said: You can use MQTT. However you cannot use B4XSerializator. Check the code and you will see that it uses B4XSerializator. Click to expand... Yes, I saw. is there another way to make this compatible? It is just a byte array I think. Upvote 0
Erel said: You can use MQTT. However you cannot use B4XSerializator. Check the code and you will see that it uses B4XSerializator. Click to expand... Yes, I saw. is there another way to make this compatible? It is just a byte array I think.
Erel B4X founder Staff member Licensed User Longtime User Feb 28, 2016 #8 Yes. Don't use B4XSerializator. You can for example send strings and then call BytesToString to convert the bytes to string. Or use ByteConverter library for other types. Upvote 0
Yes. Don't use B4XSerializator. You can for example send strings and then call BytesToString to convert the bytes to string. Or use ByteConverter library for other types.