Не удается получить сообщения из зарезервированной темы MQTT AWS IoT - PullRequest
0 голосов
/ 06 августа 2020

Я использовал basicPubSub.py для подключения к тестовым темам и успешно получил тестовые сообщения, отправленные с консоли:

2020-08-06 12:40:06,225 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Initializing MQTT layer...
2020-08-06 12:40:06,226 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Registering internal event callbacks to MQTT layer...
2020-08-06 12:40:06,227 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - MqttCore initialized
2020-08-06 12:40:06,227 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Client id: poc-v1
2020-08-06 12:40:06,227 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Protocol version: MQTTv3.1.1
2020-08-06 12:40:06,227 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Authentication type: TLSv1.2 certificate based Mutual Auth.
2020-08-06 12:40:06,228 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring endpoint...
2020-08-06 12:40:06,228 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring certificates...
2020-08-06 12:40:06,229 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring reconnect back off timing...
2020-08-06 12:40:06,229 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Base quiet time: 1.000000 sec
2020-08-06 12:40:06,229 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Max quiet time: 32.000000 sec
2020-08-06 12:40:06,229 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Stable connection time: 20.000000 sec
2020-08-06 12:40:06,229 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring offline requests queueing: max queue size: -1
2020-08-06 12:40:06,231 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring offline requests queue draining interval: 0.500000 sec
2020-08-06 12:40:06,231 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring connect/disconnect time out: 10.000000 sec
2020-08-06 12:40:06,231 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring MQTT operation time out: 5.000000 sec
2020-08-06 12:40:06,232 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync connect...
2020-08-06 12:40:06,232 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async connect...
2020-08-06 12:40:06,232 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Keep-alive: 600.000000 sec
2020-08-06 12:40:06,233 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Event consuming thread started
2020-08-06 12:40:06,233 - AWSIoTPythonSDK.core.protocol.mqtt_core - DEBUG - Passing in general notification callbacks to internal client...
2020-08-06 12:40:06,234 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in fixed event callbacks: CONNACK, DISCONNECT, MESSAGE
2020-08-06 12:40:06,363 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Starting network I/O thread...
2020-08-06 12:40:06,418 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [connack] event
2020-08-06 12:40:06,418 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [connack] event
2020-08-06 12:40:06,419 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - No need for recovery
2020-08-06 12:40:06,420 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2020-08-06 12:40:06,420 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync subscribe...
2020-08-06 12:40:06,421 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Adding a new subscription record: test/topic qos: 1
2020-08-06 12:40:06,422 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom suback event callback...
2020-08-06 12:40:06,467 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [suback] event
2020-08-06 12:40:06,467 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [suback] event
2020-08-06 12:40:06,468 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2020-08-06 12:40:06,468 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
2020-08-06 12:40:14,580 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event
2020-08-06 12:40:14,581 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event
Received a new message: 
b'{\n  "message": "Hello from AWS IoT console"\n}'
from topic: 
test/topic
--------------


2020-08-06 12:40:14,583 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2020-08-06 12:40:26,421 - AWSIoTPythonSDK.core.protocol.connection.cores - DEBUG - stableConnection: Resetting the backoff time to: 1 sec.

Но когда я пытаюсь подписаться на зарезервированные топи c $aws/things/poc-v1/tunnels/notify (моя зарегистрированная вещь - po c -v1), в нем указано, что он установил стабильное соединение, но сообщения не выводятся, когда я запускаю команду awscli.

aws iotsecuretunneling open-tunnel --destination-config thingName=poc-v1,services=ssh

туннели создаются в консоли , и я убедился, что cli использует мою IAM-роль iot all access. Кроме того, приведенная выше команда предоставляет мне исходный токен безопасности, но, похоже, не отправляет целевой токен безопасности на устройство (Raspberry Pi 3 B +). Как мне получить этот токен на свой Pi через службу управляемой доставки токенов для AWS IoT?

...