无法通过MQTT将分支设备连接到Azure Edge设备

时间:2019-10-28 15:29:19

标签: iot azure-iot-hub azure-iot-edge

我在vmware上将azure IoT Edge设备设置为ubuntu linux VM。它已连接到我的IoT中心,没有任何问题。我正在尝试注册叶设备(raspberry pi-我已成功直接连接到IoT集线器-我已从集线器中删除了该设备)。 Edge设备被设置为透明网关。当我尝试通过Edge注册设备时,收到连接被拒绝的提示。设置了边缘设备上的iptables,以将MQTT转发到位于Azure-iot-edge docker网络上的edgeHub容器。这在python sdk的设备注册示例中。我得到的确切错误是

MQTTTransportStage: _on_mqtt_connection_failure called: Connection Refused: not authorised.
MQTTTransportStage(ConnectOperation): completing with error Connection Refused: not authorised.
SerializeConnectOpsStage(ConnectOperation): op failed.  Unblocking queue with error: Connection Refused: not authorised.
EnsureConnectionStage(MQTTSubscribeOperation): Connection failed.  Completing with failure because of connection failure: Connection Refused: not authorised.
EnsureConnectionStage(MQTTSubscribeOperation): completing with error Connection Refused: not authorised.
ProvisioningMQTTConverterStage(EnableFeatureOperation): completing with error Connection Refused: not authorised.
MQTTTransportStage: _on_mqtt_disconnect called: The connection was refused.
Unhandled exception in background thread
MQTTTransportStage: disconnection was unexpected
This may cause the background thread to abort and may result in system instability.
Exception caught in background thread.  Unable to handle.
azure.iot.device.common.transport_exceptions.ConnectionFailedError: The connection was refused.

似乎转发没有发生。 这是我的iptables

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy DROP)
target     prot opt source               destination
DOCKER-USER  all  --  anywhere             anywhere
DOCKER-ISOLATION-STAGE-1  all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain DOCKER (2 references)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             172.18.0.2           tcp dpt:8883
ACCEPT     tcp  --  anywhere             172.18.0.2           tcp dpt:amqps
ACCEPT     tcp  --  anywhere             172.18.0.2           tcp dpt:https

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target     prot opt source               destination
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere

Chain DOCKER-ISOLATION-STAGE-2 (2 references)
target     prot opt source               destination
DROP       all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere

Chain DOCKER-USER (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

1 个答案:

答案 0 :(得分:0)

我的建议是,在IoT中心的“设备设置”中,确保IoTEdge设备与分支设备之间存在关联。 IoT Edge设备必须设置为叶设备的父级:

enter image description here

使用DeviceClient时,您的叶子设备必须指定GatewayHostName,并且必须是您的Edge设备(在IoT中心中设置为父设备)。 没有这个,您将得到连接拒绝错误。