Closed MiaLinke closed 7 years ago
when I am checking the messages var Message = Java.type("com.google.protobuf.Message"); Message = mqttspy.getMessages("subscription"); value of Message shows like : [pl.baczkowicz.mqttspy.messages.FormattedMqttMessage@7d2c392d, pl.baczkowicz.mqttspy.messages.FormattedMqttMessage@37ba012a, pl.baczkowicz.mqttspy.messages.FormattedMqttMessage@71f4d85a, pl.baczkowicz.mqttspy.messages.FormattedMqttMessage@9369f67, pl.baczkowicz.mqttspy.messages.FormattedMqttMessage@15cf3a3d, pl.baczkowicz.mqttspy.messages.FormattedMqttMessage@721bcaff, pl.baczkowicz.mqttspy.messages.FormattedMqttMessage@25faeaee, pl.baczkowicz.mqttspy.messages.FormattedMqttMessage@180a8491, pl.baczkowicz.mqttspy.messages.FormattedMqttMessage@74f84b7f, pl.baczkowicz.mqttspy.messages.FormattedMqttMessage@58982b2d] please clear this format .. Waiting for reply
Thanks in Advance.. :)
Hi @MiaLinke,
I don't think you are using Protobuf in the right way. You might need to do some more googling on that. I suspect you first need to get the binary payload from a FormattedMqttMessage, and then turn it into a Protobuf message.
Here are examples in mqtt-spy and Kura:
Thank you.. how can i get binary payload (in the form of 10010010010010101010 ) while from rawpayload i can get the byte data like B@34512d53 how to parse that data. it gives me error Parser.parseFrom() is not a function but I had already imported in my script file.(var Parser = Java.type("com.google.protobuf.Parser")) oder I also tried the KuraPayloadFormatter.format(Message.get(0).getRawPayload()) output for this is Message or its encoding is invalid..
waiting for reply.. :)
@MiaLinke, the getRawPayload() method returns an array of bytes (byte[]). What type does your parseFrom() expect?
Thank you Yes that I understand... I am trying to write code for protobuf in pubsub Script without modifying the mqtt-spy-0.5.4-jar-with-dependencies.jar file. I tried : Clone the code and after build jar and when I run that jar shows me error for javafx.fxml.LoadException. I am trying for return type for parser function String or JSON.
Waiting for reply :)
sorry, i dont understand...
Sorry.. i am new to these concepts but i decided to use my protobuf compiled files jar as dependency and then use same while i want to use my own proto files. will you please tell me for the javafx.fxml.LoadException that comes at the time of opening the sample local broker..Thank you.. :) und i think after that it will be better to close this issue.
I think there is an easier way - rather than recompiling the whole project, put your JAR on the classpath as explained in https://github.com/kamilfb/mqtt-spy/wiki/GettingStarted. Look for the "Running with additional JARs on the classpath" heading.
All working perfectly and mainly with protobuf formatting.. :) Thank you once agin ..
hi @MiaLinke - cool - well done! any chance you could share your final solution so that other people can benefit from this as well?
Yes. I will do it definitely to help others. will you please tell me the working of this: var Payload = message.size() > 0 ? message.get(0).getRawPayload() : " ";
I published my protobuf encoded bytearray object in Pubsub script (newBuilder and then toByteArray).
when I doing protobuf parsefrom then i get the string value correct but Id is false. My proto file had message with int32 Id and String data value. parsefrom return getData value correct but int32 getId not ex: published Id=1234 returned parsed getId value is 19881967. but for Id=121 or 122 or 101 kind of Id received correct decoded value received.
Please tell me where I am going wrong.
@kamilfb I found out the reason (reference :https://github.com/dcodeIO/protobuf.js/issues/192): It happen because there is some sort of string conversion in between (which is a common cause of such issues) that corrupts non-ASCII values . But I am not getting that with pubsub script ..(send bytearray and received bytearray are different) Please reply.. Thanks in advance.
@MiaLinke , I'm not sure why it doesn't work - looks like a protobuf thing... :(
Hello Kamil, I am trying to encode the messages then publish it to client and again decode it in the PubSub Test Script in Test cases pane... to see correct message received pass the Test else Fail. Please let me know if you need more information. waiting for reply.
Thank you in Advance.. :)