python - AWS IOT 和 Worker:如何从另一个账户发布 iot msg
问题描述
我正在尝试从另一个 AWS 账户发布 iot msg。
我现在的情况:
作为要求,我有 2 个不同的 AWS 账户 => (1) 用于工作人员,(2) 用于 iOT
- 我从 (2) 获得 IAM 用户凭证(访问密钥、秘密密钥)
- 我创建了一个 python 工作环境以在 (1) 上使用 SQS 消息 => 工作人员将处理 SQS 消息并发布 IoT 消息。
我的工人代码:application.py(使用boto3,python):
import boto3
import flask
from flask import request, Response
iot_client = boto3.client(
'iot-data',
aws_access_key_id='XXXXXXXX',
aws_secret_access_key='xxxxxxxxxx',
region_name='eu-west-1'
)
application = flask.Flask(__name__)
application.config.from_object('default_config')
application.debug = application.config['FLASK_DEBUG'] in ['true', 'True']
@application.route('/myworker', methods=['POST'])
def myworker():
iot_client.publish(
topic='mytopic',
qos=0,
payload= request
)
response = Response("", status=200)
我上传,部署到worker,并向SQS发送消息,worker开始轮询SQS消息,但我得到了错误
对于可迭代的项目:
TypeError:“ParamValidationError”对象不可迭代
处理 WSGI 脚本“/opt/python/current/app/application.py”时发生异常。
似乎我错误地初始化了客户端,或者其他原因导致了错误。
任何建议表示赞赏。
******* 更新 **********
我提取错误日志如下
[Thu Dec 27 16:06:27.425505 2018] [:error] [pid 3383] [remote 127.0.0.1:16] for item in iterable:
[Thu Dec 27 16:06:27.425517 2018] [:error] [pid 3383] [remote 127.0.0.1:16] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:06:32.509920 2018] [:error] [pid 3383] [remote 127.0.0.1:12] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:06:32.510017 2018] [:error] [pid 3383] [remote 127.0.0.1:12] Traceback (most recent call last):
[Thu Dec 27 16:06:32.510048 2018] [:error] [pid 3383] [remote 127.0.0.1:12] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:06:32.510052 2018] [:error] [pid 3383] [remote 127.0.0.1:12] return self._next()
[Thu Dec 27 16:06:32.510058 2018] [:error] [pid 3383] [remote 127.0.0.1:12] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:06:32.510061 2018] [:error] [pid 3383] [remote 127.0.0.1:12] for item in iterable:
[Thu Dec 27 16:06:32.510077 2018] [:error] [pid 3383] [remote 127.0.0.1:12] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:06:37.585597 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:06:37.585693 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] Traceback (most recent call last):
[Thu Dec 27 16:06:37.585717 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:06:37.585721 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] return self._next()
[Thu Dec 27 16:06:37.585726 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:06:37.585729 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] for item in iterable:
[Thu Dec 27 16:06:37.585742 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:06:42.682277 2018] [:error] [pid 3383] [remote 127.0.0.1:16] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:06:42.682377 2018] [:error] [pid 3383] [remote 127.0.0.1:16] Traceback (most recent call last):
[Thu Dec 27 16:06:42.682400 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:06:42.682404 2018] [:error] [pid 3383] [remote 127.0.0.1:16] return self._next()
[Thu Dec 27 16:06:42.682410 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:06:42.682413 2018] [:error] [pid 3383] [remote 127.0.0.1:16] for item in iterable:
[Thu Dec 27 16:06:42.682430 2018] [:error] [pid 3383] [remote 127.0.0.1:16] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:06:47.750299 2018] [:error] [pid 3383] [remote 127.0.0.1:16] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:06:47.750394 2018] [:error] [pid 3383] [remote 127.0.0.1:16] Traceback (most recent call last):
[Thu Dec 27 16:06:47.750417 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:06:47.750421 2018] [:error] [pid 3383] [remote 127.0.0.1:16] return self._next()
[Thu Dec 27 16:06:47.750427 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:06:47.750430 2018] [:error] [pid 3383] [remote 127.0.0.1:16] for item in iterable:
[Thu Dec 27 16:06:47.750443 2018] [:error] [pid 3383] [remote 127.0.0.1:16] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:06:52.948113 2018] [:error] [pid 3383] [remote 127.0.0.1:12] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:06:52.948206 2018] [:error] [pid 3383] [remote 127.0.0.1:12] Traceback (most recent call last):
[Thu Dec 27 16:06:52.948238 2018] [:error] [pid 3383] [remote 127.0.0.1:12] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:06:52.948243 2018] [:error] [pid 3383] [remote 127.0.0.1:12] return self._next()
[Thu Dec 27 16:06:52.948249 2018] [:error] [pid 3383] [remote 127.0.0.1:12] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:06:52.948252 2018] [:error] [pid 3383] [remote 127.0.0.1:12] for item in iterable:
[Thu Dec 27 16:06:52.948268 2018] [:error] [pid 3383] [remote 127.0.0.1:12] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:06:58.001714 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:06:58.001827 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] Traceback (most recent call last):
[Thu Dec 27 16:06:58.001849 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:06:58.001853 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] return self._next()
[Thu Dec 27 16:06:58.001859 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:06:58.001862 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] for item in iterable:
[Thu Dec 27 16:06:58.001874 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:07:03.047906 2018] [:error] [pid 3383] [remote 127.0.0.1:16] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:07:03.048017 2018] [:error] [pid 3383] [remote 127.0.0.1:16] Traceback (most recent call last):
[Thu Dec 27 16:07:03.048040 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:07:03.048043 2018] [:error] [pid 3383] [remote 127.0.0.1:16] return self._next()
[Thu Dec 27 16:07:03.048049 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:07:03.048052 2018] [:error] [pid 3383] [remote 127.0.0.1:16] for item in iterable:
[Thu Dec 27 16:07:03.048065 2018] [:error] [pid 3383] [remote 127.0.0.1:16] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:07:08.109607 2018] [:error] [pid 3383] [remote 127.0.0.1:16] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:07:08.109702 2018] [:error] [pid 3383] [remote 127.0.0.1:16] Traceback (most recent call last):
[Thu Dec 27 16:07:08.109723 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:07:08.109727 2018] [:error] [pid 3383] [remote 127.0.0.1:16] return self._next()
[Thu Dec 27 16:07:08.109733 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:07:08.109736 2018] [:error] [pid 3383] [remote 127.0.0.1:16] for item in iterable:
[Thu Dec 27 16:07:08.109748 2018] [:error] [pid 3383] [remote 127.0.0.1:16] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:07:13.161710 2018] [:error] [pid 3383] [remote 127.0.0.1:12] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:07:13.161809 2018] [:error] [pid 3383] [remote 127.0.0.1:12] Traceback (most recent call last):
[Thu Dec 27 16:07:13.161840 2018] [:error] [pid 3383] [remote 127.0.0.1:12] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:07:13.161856 2018] [:error] [pid 3383] [remote 127.0.0.1:12] return self._next()
[Thu Dec 27 16:07:13.161863 2018] [:error] [pid 3383] [remote 127.0.0.1:12] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:07:13.161866 2018] [:error] [pid 3383] [remote 127.0.0.1:12] for item in iterable:
[Thu Dec 27 16:07:13.161879 2018] [:error] [pid 3383] [remote 127.0.0.1:12] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:07:18.206671 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:07:18.206766 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] Traceback (most recent call last):
[Thu Dec 27 16:07:18.206788 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:07:18.206793 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] return self._next()
[Thu Dec 27 16:07:18.206798 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:07:18.206801 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] for item in iterable:
[Thu Dec 27 16:07:18.206814 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:07:23.270210 2018] [:error] [pid 3383] [remote 127.0.0.1:16] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:07:23.270305 2018] [:error] [pid 3383] [remote 127.0.0.1:16] Traceback (most recent call last):
[Thu Dec 27 16:07:23.270369 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:07:23.270374 2018] [:error] [pid 3383] [remote 127.0.0.1:16] return self._next()
[Thu Dec 27 16:07:23.270392 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:07:23.270395 2018] [:error] [pid 3383] [remote 127.0.0.1:16] for item in iterable:
[Thu Dec 27 16:07:23.270408 2018] [:error] [pid 3383] [remote 127.0.0.1:16] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:07:28.318729 2018] [:error] [pid 3383] [remote 127.0.0.1:16] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:07:28.318825 2018] [:error] [pid 3383] [remote 127.0.0.1:16] Traceback (most recent call last):
[Thu Dec 27 16:07:28.318848 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:07:28.318852 2018] [:error] [pid 3383] [remote 127.0.0.1:16] return self._next()
[Thu Dec 27 16:07:28.318858 2018] [:error] [pid 3383] [remote 127.0.0.1:16] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:07:28.318861 2018] [:error] [pid 3383] [remote 127.0.0.1:16] for item in iterable:
[Thu Dec 27 16:07:28.318873 2018] [:error] [pid 3383] [remote 127.0.0.1:16] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:07:33.368395 2018] [:error] [pid 3383] [remote 127.0.0.1:12] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:07:33.368498 2018] [:error] [pid 3383] [remote 127.0.0.1:12] Traceback (most recent call last):
[Thu Dec 27 16:07:33.368520 2018] [:error] [pid 3383] [remote 127.0.0.1:12] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:07:33.368524 2018] [:error] [pid 3383] [remote 127.0.0.1:12] return self._next()
[Thu Dec 27 16:07:33.368538 2018] [:error] [pid 3383] [remote 127.0.0.1:12] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:07:33.368541 2018] [:error] [pid 3383] [remote 127.0.0.1:12] for item in iterable:
[Thu Dec 27 16:07:33.368554 2018] [:error] [pid 3383] [remote 127.0.0.1:12] TypeError: 'ParamValidationError' object is not iterable
[Thu Dec 27 16:07:38.476527 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] mod_wsgi (pid=3383): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Thu Dec 27 16:07:38.476616 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] Traceback (most recent call last):
[Thu Dec 27 16:07:38.476637 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wsgi.py", line 682, in __next__
[Thu Dec 27 16:07:38.476641 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] return self._next()
[Thu Dec 27 16:07:38.476646 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
[Thu Dec 27 16:07:38.476649 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] for item in iterable:
[Thu Dec 27 16:07:38.476661 2018] [:error] [pid 3383] [remote 127.0.0.1:17936] TypeError: 'ParamValidationError' object is not iterable
解决方案
推荐阅读
- javascript - Get alerted when the value of select (dropdown) became empty
- python - 单击 Selenium Python 中的按钮
- c# - 如何将 AllowAnonymousAttribute 添加到来自自定义中间件的路由/请求?
- python - 给定 Bokeh python 的标准,如何在 GMAP 上显示不同的数据点
- reactjs - 建立投资组合网站,我想包括我的 github 链接
- gif - 我将如何制作自己的 GIF 启动器?
- ruby-on-rails - 根据日期获取一个季节内的事件数量
- c# - C# 将基本 JSON 记录重新格式化为标头和详细信息输出
- npm - 在管道部署期间找不到模块
- python - 如何在 Flask 中返回获取 JSON POST 请求的数据库?