以下是我写的代码
from boto3.session import Session session = Session(aws_access_key_id='**', aws_secret_access_key='**', region_name='us-west-2') clientz = session.client('sqs') queue = clientz.get_queue_url(QueueName='queue_name') print queue responses = queue.send_message(MessageBody='Test') print(response.get('MessageId'))
{u'QueueUrl':' https://us-west-2.queue.amazonaws.com/@@/queue_name','ResponseMetadata ':{'HTTPStatusCode':200,'RequestId':'@@'}}
回溯(最近一次调用最后):文件“publisher_dropbox.py”,第77行,在response =queue.send_message(MessageBody ='Test')
AttributeError:“dict”对象没有属性“send_message”
我不确定“dict”对象是什么,因为我没有在任何地方指定它。
我对 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
订阅命令是:
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