Closed mjkapkan closed 2 years ago
This is caused by the underlying lib which is using string as argument. github.com/eclipse/paho.mqtt.golang
The clean way to fix this would be to fix it in there.
can you give me a js sample file sending binary in js so I can test : I made a fix in https://github.com/pmalhaire/xk6-mqtt/tree/byte_array_support
Thanks. Just try encoding any string with CBOR. For example this one https://github.com/paroga/cbor-js
Basically I encode before sending and decode after receiving.
The thing needed for this is the way to convert js array to golang []byte and back.
note you can do the binary to hex and hex to binary in the js code instead of injecting it in golang.
Yeah. I actually do that. But the thing that was missing was to be able to send bytes in the mqtt message. As before my modification it was converting everything to string. Will try out the new version and let you know how it works. Thanks again!
The issues is that the js arraybuffer does not have a corresponding golang type (or at least I did not find how to do it) so I am kindof stucked on this for now.
This is because the Message argument on Publish function is declared as string.