This topic describes how to fix the sub-device disconnection issue.

Devices connected to a gateway are called sub-devices. If a sub-device is not in the online or active state, follow these steps to fix the issue:

Step 1: Make sure that you use the commands generated by the IoT Platform console to install and start Link IoT Edge

The commands generated by the IoT Platform console free you from manual installation operations, thereby eliminating errors caused by manual operations.

For more information, see Install and start Link IoT Edge in Build an environment.

Step 2: Make sure that all services are in the active state

Run the following command in a shell multiple times to check whether all services remain in the active state:
/linkedge/gateway/build/script/iot_gateway_status.sh
  • If the output is as follows, all services are in the active state.Output
  • If the output indicates that some services are in the inactive state, run the following command as the root user to restart Link IoT Edge:
    sudo /linkedge/gateway/build/script/iot_gateway_start.sh

    Run the /linkedge/gateway/build/script/iot_gateway_status.sh command again to check whether all services are in the active state. If a service is still in the inactive state, follow these steps to start it:

    1. View logs in the userlog directory and logs of the service.
      • The path of the userlog directory is /linkedge/run/logger/userlog.
      • Logs of the service are stored in /linkedge/run/logger/<service_name>, where <service_name> indicates the name of the service.
    2. Manually start the service and view logs of the service.
If the logger service fails to start, run the ifconfig command to check whether the loopback interface is in the up state.
ifconfig lo
If the loopback interface is not in the up state, run the following command to change its status to up:
sudo ifconfig lo up

If any service remains in the inactive state after you complete the preceding operations, analyze the cause based on the logs of the service.

Step 3: Make sure that the gateway is online

Log on to the IoT Platform console and check whether the gateway is online. If the gateway is offline, run the following command to diagnose the cause:

cd /linkedge/gateway/build/bin/ && ./lectl diagnose

In normal cases, OK is displayed next to each operation in the command output, as shown in the following figure.

Normal status of the gateway

If the gateway is offline, the possible causes are as follows:

  • The certificate of the gateway device fails to be obtained.

    Workaround: Run the cd /linkedge/gateway/build/bin/ && ./lectl config set -g $your_productkey $your_devicename $your_devicesecret command to import the certificate of the gateway device.

  • The network is abnormal.

    Workaround: Stop the firewall from blocking the connection and disable the HTTP proxy and iptables on the gateway device.

  • The certificate of the gateway device is incorrect.

    Workaround: Run the ./lectl config set -g command to import the correct certificate of the gateway device.

Step 4: Make sure that the driver runs properly after the edge instance is deployed

Run the following command multiple times to view the driver status:
cd /linkedge/gateway/build/bin && ./lectl fc show

The following output indicates that the driver is running properly.

Output

In the output, FunctionName indicates the driver name and StartTime indicates the time when the driver started.

  • If the value of StartTime in the output keeps changing, the driver keeps exiting and starting. In this case, analyze logs of the driver to locate the cause.
  • If the value of State in the output is not Success, make sure that:
    • The driver is packed into a .zip package, and the binary or index file of the driver is located in the top-level directory of the .zip package.
    • The main file of the driver is executable if the driver is programmed in C.
    • The unzip tool is installed in the runtime environment of Link IoT Edge.

Step 5: Make sure that the driver properly communicates with the sub-device

View logs about communication between the driver and sub-device.

If the communication between the driver and sub-device is abnormal, the possible causes are as follows:

  • The driver assigned to the edge instance for managing the sub-device is incorrectly configured in the IoT Platform console.

    Workaround: Log on to the IoT Platform console, go to the Instance Details page, and then click the Devices & Drivers tab. Modify the driver configuration, and then redeploy the edge instance.

  • The communication link between the driver and sub-device is abnormal.

    Workaround: Verify the physical connection and cancel network blocking on the firewall.

Step 6: Make sure that the correct certificate information is configured for registering each sub-device

Run the following command to obtain the certificate information, including ProductKey and DeviceName, about all sub-devices under your Alibaba Cloud account:
cd /linkedge/gateway/build/bin && ./lectl config get -d
The output is as follows.Output

In the output, value Used of State indicates that the certificate of the sub-device has been used for registration, and value Unused indicates not. Check the certificate of the sub-device whose value of State is Unused and make sure that the sub-device uses the correct certificate.

Step 7: Submit a ticket to apply for technical support

If some sub-devices are still offline after you complete the preceding steps, submit a ticket to report the issue and apply for technical support. When submitting a ticket, you must provide sub-device information and operational logs. For more information, see Submit a ticket.

Appendix

  • Log file directories
    Log files of each module of Link IoT Edge are stored in /linkedge/run/logger, as shown in the following figure.Output
    Note
    • Log files of each driver are stored in a separate directory named after the driver name in the fc-base/ directory. For example, log files of the Light driver are stored in the fc-base/Light directory.
    • Error log files in the userlog directory record errors such as operation process errors and configuration errors. Generally, these errors cannot be automatically fixed.
  • Log files in the userlog directory
    • Logs of the device info manager unit (dimu) module
      [CloudOffline][Succeeded]: Device cloud ID: [%s]
      Indicates that a sub-device is disconnected from IoT Platform. The cloud ID of the sub-device is in the productkey_devicename format. The cloud ID of a sub-device indicates the ID of the sub-device in IoT Platform.
      [CloudOffline][Failed]: Device cloud ID: [%s]
      Indicates that a sub-device fails to be disconnected from IoT Platform.
      [LocalOffline][Failed]: Device local ID: [], Cloud ID is illegal: %s
      Indicates that a sub-device fails to be disconnected from the gateway because the cloud ID is incorrect.
      [LocalOffline][Failed]: Device local ID: [], can not find specified Cloud ID: %s
      Indicates that a sub-device fails to be disconnected from the gateway because no cloud ID is specified.
      [LocalOffline][Succeeded]: Device cloud ID: [%s]
      Indicates that a sub-device is disconnected from the gateway.
      [Authorization][Failed]: Unable to authorize device %s with Product Key %s : error code: %d.
      Indicates that a sub-device fails to be registered due to the specific error.
      [LocalOnline][Succeeded]: Device cloud ID: [%s]
      Indicates that a sub-device is connected to the gateway.
      [CloudOnline][Failed]: Device cloud ID: [%s], is a local device
      Indicates that a sub-device fails to be connected to IoT Platform because the sub-device is a local one.
      [CloudOnline][Succeeded]: Device cloud ID: [%s]
      Indicates that a sub-device is connected to IoT Platform.
      [CloudOnline][Failed]: Device cloud ID: [%s]
      Indicates that a sub-device fails to be connected to IoT Platform.
    • Logs of the cloud-proxy module
      [gateway_connect_cloud]gateway online! productkey=%s, devicename=%s
      Indicates that the gateway goes online.
      [gateway_connect_cloud]gateway offline! productkey=%s, devicename=%s
      Indicates that the gateway is offline because the network is disconnected.