我遇到了Edge设备的问题。 即使没有设备发送任何数据,即使没有消息发送,消息配额也会看到大量流量。 例如,在7小时左右的时间内将累积14000条消息。
有没有办法调试内部消息?
我已经使用docker logs edgeHub
和docker logs edgeAgent
进行了检查,但没有任何异常。
答案 0 :(得分:0)
如果它可以帮助某人,那么昨天我遇到了此类问题,它使用Python测试应用程序从我的边缘设备发送消息,却再也没有在云上找到它。我错过了send_message函数的异步行为。
您应该有类似的东西:
# At the beginning of you code
# Create an IoT Hub client
client = IoTHubModuleClient.create_from_edge_environment()
# connect the client.
await client.connect()
# ... and in your main loop
# Send the message.
await client.send_message(message)
您的Python应用程序应使用asyncio。如果您忘记了await
的send_message,您的代码将不会产生错误,但将无法正常工作。
如果有效,您应该会看到一堆带有docker logs
的Python应用程序的Azure sdk调试日志,例如:
2020-04-29 08:00:13,032 - async_clients - azure.iot.device.iothub.aio.async_clients - INFO - Sending message to Hub...
2020-04-29 08:00:13,032 - pipeline_thread - azure.iot.device.common.pipeline.pipeline_thread - DEBUG - Starting run_op in pipeline thread
2020-04-29 08:00:13,033 - pipeline_ops_base - azure.iot.device.common.pipeline.pipeline_ops_base - DEBUG - SendD2CMessageOperation: creating worker op of type MQTTPublishOperation
2020-04-29 08:00:13,033 - pipeline_stages_base - azure.iot.device.common.pipeline.pipeline_stages_base - INFO - AutoConnectStage(MQTTPublishOperation): Connected. Sending down and adding callback to check result
2020-04-29 08:00:13,033 - pipeline_stages_mqtt - azure.iot.device.common.pipeline.pipeline_stages_mqtt - INFO - MQTTTransportStage(MQTTPublishOperation): publishing on devices/<DEVICE NAME>/modules/<MODULE_NAME>/messages/events/<PROPERTIES>
2020-04-29 08:00:13,033 - mqtt_transport - azure.iot.device.common.mqtt_transport - INFO - publishing on devices/<DEVICE NAME>/modules/<MODULE_NAME>/messages/events/<PROPERTIES>
2020-04-29 08:00:13,033 - client - paho - DEBUG - Sending PUBLISH (d0, q1, r0, m8), 'b'devices/<DEVICE NAME>/modules/<MODULE_NAME>/messages/events/<PROPERTIES>'', ... (65 bytes)
2020-04-29 08:00:13,033 - mqtt_transport - azure.iot.device.common.mqtt_transport - DEBUG - _mqtt_client.publish returned rc=0
2020-04-29 08:00:13,033 - mqtt_transport - azure.iot.device.common.mqtt_transport - DEBUG - Waiting for response on MID: 8
2020-04-29 08:00:13,046 - client - paho - DEBUG - Received PUBACK (Mid: 8)
2020-04-29 08:00:13,047 - mqtt_transport - azure.iot.device.common.mqtt_transport - INFO - payload published for 8
2020-04-29 08:00:13,047 - mqtt_transport - azure.iot.device.common.mqtt_transport - DEBUG - Response received for recognized MID: 8 - triggering callback
2020-04-29 08:00:13,048 - pipeline_thread - azure.iot.device.common.pipeline.pipeline_thread - DEBUG - Starting on_published in pipeline thread
2020-04-29 08:00:13,048 - pipeline_stages_mqtt - azure.iot.device.common.pipeline.pipeline_stages_mqtt - DEBUG - MQTTTransportStage(MQTTPublishOperation): PUBACK received. completing op.
2020-04-29 08:00:13,049 - pipeline_ops_base - azure.iot.device.common.pipeline.pipeline_ops_base - DEBUG - MQTTPublishOperation: completing without error
2020-04-29 08:00:13,049 - pipeline_ops_base - azure.iot.device.common.pipeline.pipeline_ops_base - DEBUG - SendD2CMessageOperation: Worker op (MQTTPublishOperation) has been completed
2020-04-29 08:00:13,050 - pipeline_ops_base - azure.iot.device.common.pipeline.pipeline_ops_base - DEBUG - SendD2CMessageOperation: completing without error
2020-04-29 08:00:13,050 - pipeline_thread - azure.iot.device.common.pipeline.pipeline_thread - DEBUG - Starting on_complete in callback thread
2020-04-29 08:00:13,051 - async_adapter - azure.iot.device.common.async_adapter - DEBUG - Callback completed with result None
2020-04-29 08:00:13,051 - async_clients - azure.iot.device.iothub.aio.async_clients - INFO - Successfully sent message to Hub
关于此:
即使没有设备正在发送任何数据,消息配额为 即使没有消息发送也看到很多流量
请注意对Total number of messages used
的错误解释。您应该看的真正价值是Telemetry messages sent