📜 ⬆️ ⬇️

Cross-platform IoT: Troubleshooting

Hi, Habr! Earlier, we looked at the Azure IoT CLI and the IoT Center Browser, which are designed to control the center, devices, as well as send and receive messages. In this post we will discuss a troubleshooting program that provides additional support and features for the IoT Center. Look under the cat!



Cycle of articles "Cross-platform IoT"


1. Cross-platform IoT: Using Azure CLI and Azure IoT Hub
2. Cross-platform IoT: Device Operations
3. Cross-platform IoT: Troubleshooting

What is the diagnostic program for?


There are situations when something goes wrong and you are trying to determine the cause. The hardest thing is usually with a network connection, whether it is blocking the port with a firewall or not enough bandwidth. And the result is one - an unstable connection. Since monitoring operations for the IoT Center is provided through the Azure Management Portal, as well as the IoT Center endpoint, a thorough study of logs and crash dumps can take valuable time and require more than one support request to open. The IoT Center Diagnostic Program is a recent addition to the IoT Center Toolkit. This is an effective communications test utility that provides initial data on potential failures in case the IoT center is not functioning properly.
')
The tool is also written in node.js and is an open source software (MIT) solution. To install the tool on your equipment, run the following command in the terminal:

npm install -g iothub-diagnostics 

Running the diagnostic tool is quite simple, all you need is the connection string of your IoT center. No other options or commands are provided.

Judging by the results of my tests, the tool requires permission iothubowner . I did not try to apply it with all policies, you can probably restrict access or use policies with a lower level of rights.

 iothub-diagnostics "HostName=youriothub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey==" 

Once the connection is established, the tool starts to perform a series of tests:

  1. First, network tests are performed to verify DNS resolution, the program checks the connection with the URL to make sure that an Internet connection is possible. At the moment, pingURL is linked to http://www.microsoft.com . The code provides an indication of your DNS or address, so that you can make the settings at your discretion.
  2. Next, it checks the availability of ports and the requirements of TLS encryption. In this case, the tests also include a check of communication over HTTPS (443), by default httpsRequestUrl is tied to https://www.microsoft.com .
  3. The last stage of verification is performed in the very center: a temporary device is first registered, and then the D2C connections (devices to the cloud) and C2D (clouds to the device) are tested using all supported protocols: (HTTPS (443), AMQP (5672 and 5671) and MQTT (1833 and 8883)).

The result obtained at the end of the test should look like this:

 2017-03-16T07:38:51.193Z - info: ******************************************* 2017-03-16T07:38:51.196Z - info: * Executing the Microsoft IOT Trace tool. * 2017-03-16T07:38:51.196Z - info: ******************************************* 2017-03-16T07:38:51.197Z - info: 2017-03-16T07:38:51.198Z - info: --- Executing network tests --- 2017-03-16T07:38:51.222Z - info: 2017-03-16T07:38:51.223Z - info: Starting DNS resolution for host 'www.microsoft.com'... 2017-03-16T07:38:51.254Z - info: --> Successfully resolved DNS to 23.204.149.152. 2017-03-16T07:38:51.255Z - info: 2017-03-16T07:38:51.255Z - info: Pinging IPV4 address '23.204.149.152'... 2017-03-16T07:38:51.291Z - info: --> Successfully pinged 23.204.149.152 2017-03-16T07:38:51.291Z - info: 2017-03-16T07:38:51.291Z - info: Sending https request to 'https://www.microsoft.com/' 2017-03-16T07:38:51.444Z - info: --> Completed https request 2017-03-16T07:38:51.445Z - info: 2017-03-16T07:38:51.445Z - info: --- Executing IOT Hub tests --- 2017-03-16T07:38:54.731Z - info: 2017-03-16T07:38:54.732Z - info: Starting AMQP Test... 2017-03-16T07:38:59.141Z - info: --> Successfully ran AMQP test. 2017-03-16T07:38:59.142Z - info: 2017-03-16T07:38:59.142Z - info: Starting AMQP-WS Test... 2017-03-16T07:39:03.460Z - info: --> Successfully ran AMQP-WS test. 2017-03-16T07:39:03.466Z - info: 2017-03-16T07:39:03.466Z - info: Starting HTTPS Test... 2017-03-16T07:39:08.036Z - info: --> Successfully ran HTTPS test. 2017-03-16T07:39:08.059Z - info: 2017-03-16T07:39:08.060Z - info: Starting Mqtt Test... 2017-03-16T07:39:11.828Z - info: --> Successfully ran Mqtt test. 

In the event of an error during testing, the corresponding exception will be recorded in a log and displayed on the screen.

In general, the diagnostic tool is a great, small program to quickly scan your environment for common connectivity issues and device operations. Note that this tool does not support network monitoring or tracing for IoT Center servers. It is designed to connect clients and test basic IoT operations.

Of course, you can add additional functions and reporting tools to it, which allows you to get more information about the types of tests conducted. I would like the tool to be integrated into the CI / CD channel, and the tests of the basic operations have been extended with the help of our own development tests.

Source: https://habr.com/ru/post/343794/


All Articles