Does mosquitto_pub convert a binary file to ASCII?

孤者浪人 提交于 2019-12-11 23:32:47

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!