简体   繁体   English

如何使用WireShark对从本地计算机发送到Azure IOT集线器的消息进行故障排除?

[英]How to troubleshoot messages sent from local compter to Azure IOT Hub using WireShark?

I am sending messages from my C# application to IOT Hub using below code snippet. 我正在使用以下代码段将消息从C#应用程序发送到IOT Hub

    public async Task<MessageToTargetStatus> ForwardMessage(byte[] message)
    {
        var messageToSend = new Microsoft.Azure.Devices.Client.Message(message);            
        await iotHubClient.GetDeviceClient().SendEventAsync(messageToSend).ConfigureAwait(false);
        return MessageToTargetStatus.Success;
    }

Messages are successfully received at the Azure IOT Hub Azure IOT Hub成功接收到消息

Now I want to test my security of these messages and trying to verify these messages in WireShark. 现在,我想测试这些消息的安全性,并尝试在WireShark中验证这些消息。

I see many records in WireShark , but I am not able to figure out which is my messages sent to IOT Hub. 我在WireShark看到许多记录,但是我无法确定发送到IOT Hub的消息是哪一条。

How can I do it? 我该怎么做? I am using MQTT at port 1833, running as `Windows Service'. 我正在以“ Windows Service”运行的端口1833上使用MQTT

I have added filter as follow, but no luck 我添加了以下过滤器,但是没有运气

在此处输入图片说明

MQTT I might need to force the packets over a networkadapter, using localhost windows will use loopback instead of the network interface card. MQTT我可能需要通过网络适配器强制发送数据包,使用localhost的Windows将使用环回而不是网络接口卡。 So how can I do it in WireShark? 那么如何在WireShark中做到这一点?

Updated question with Device Explorer tool screenshot 设备资源管理器工具屏幕截图更新了问题

When I send single message from Device Explorer , I see many communication records in WireShark . Device Explorer发送单个消息时,我在WireShark看到许多通信记录。 Which protocol I should be filtering? 我应该过滤哪个协议?

在此处输入图片说明

Connection string - I am using Mqtt_WebSocket_Only 连接字符串 -我正在使用Mqtt_WebSocket_Only

  _hubClient = DeviceClient.CreateFromConnectionString(IotHubConnectionString, TransportType.Mqtt_WebSocket_Only);

Azure IoT Hub only supported security communication, for MQTT protocol it use 8883 port number. Azure IoT中心仅支持安全通信,对于MQTT协议,它使用8883端口号。 So you need change capture filter to tcp.port == 8883 . 因此,您需要将捕获过滤器更改为tcp.port == 8883

Ref: Azure IoT Hub communication protocol and ports 参考: Azure IoT中心通信协议和端口

Or find the Azure IoT Hub IP address using the following command: 或使用以下命令找到Azure IoT中心IP地址:

ping [your-hub-name].azure-devices.net

Then use this filter: 然后使用此过滤器:

ip.addr == [iothub-address]

If you use AMQP, its port is 5671. You can set filter in Wireshark like this: 如果使用AMQP,则其端口为5671。可以在Wireshark中设置过滤器,如下所示:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM