问题
I am quite new to MQTT protocol and I am sorry if my question sounds stupid. I am publishing an image from a device and when I subscribe to it on CLI I can see some characters which are not in the binary format. So my question is when the image is published does it by default get converted to ASCII format and then sent or is it received in the ASCII format or some other format?
The publish command I am giving is:
mosquitto_pub --cafile /home/pi/nirupama/rootCA.pem --cert /home/pi/nirupama/certificate.pem --key /home/pi/nirupama/private.pem -h xxxxxxxxxxxxxx.iot.us-west-2.amazonaws.com -p 8883 -q 1 -d -t $aws/things/raspberry-pi/shadow/update -i mqtt_test -f /media/webcam/picture.jpg
The subscribe command is:
mosquitto_sub --cafile /home/pi/nirupama/rootCA.pem --cert /home/pi/nirupama/certificate.pem --key /home/pi/nirupama/private.pem -h xxxxxxxxxxxxxx.iot.us-west-2.amazonaws.com -p 8883 -q 1 -d -t $aws/things/raspberry-pi/shadow/update -i mqtt_test1
回答1:
This question was answered on the MQTT mailing list by JP Mens: https://groups.google.com/forum/#!topic/mqtt/MIwf0-Bi9yM
The answer is that MQTT in a binary protocol and they payloads are not converted to ASCII or any other text format. You should indeed be able to send binary image payloads without corruption.
来源:https://stackoverflow.com/questions/36190872/does-mosquitto-pub-convert-a-binary-file-to-ascii