-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binary payloads not supported? #109
Comments
agree, the user should do the encoding/decoding |
I also run into this problem, maybe provide an option for the user to get binary payloads. |
Yeah, this was just a cut corner to get things working quickly. Perhaps a |
I see, makes sense. Turns out I habitually send stringified JSON when not sending binary, and apparently JSON.parse() can handle a Buffer containing a string. |
So is there an example or test using an encoding other than utf8? I am trying to send binary messages. Basically want to try out msgpack. Cheers |
OK I found it. client = mqtt.createClient({encoding: 'binary'}); If you like I will update the readme and add a test. |
Please do so! Thanks a million! Il giorno lunedì 2 settembre 2013, Mark Wolfe ha scritto:
|
I might be missing something, but it seems binary payloads are not supported because of this line, where we are converting the buffer to a utf8 string:
https://github.com/adamvr/MQTT.js/blob/master/lib/parse.js#L122
Leaving it as a buffer solves my problem, eg:
packet.payload = buf.slice(pos, len);
What is the thinking here? A simple test like so reproduces the problem:
The text was updated successfully, but these errors were encountered: