mosquitto_pub是否将二进制文件转换为ASCII?

时间:2016-03-23 23:48:26

标签: mqtt mosquitto

我对MQTT协议很新,如果我的问题听起来很愚蠢,我很抱歉。我正在从设备发布图像,当我在CLI上订阅它时,我可以看到一些不是二进制格式的字符。所以我的问题是图像发布时是默认转换为ASCII格式然后发送还是以ASCII格式或其他格式接收?

我给出的发布命令是:

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

subscribe命令是:

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 个答案:

答案 0 :(得分:3)

JP Mens在MQTT邮件列表中回答了这个问题: https://groups.google.com/forum/#!topic/mqtt/MIwf0-Bi9yM

答案是二进制协议中的MQTT及其有效负载不会转换为ASCII或任何其他文本格式。您确实应该能够在不损坏的情况下发送二进制图像有效负载。