AzureIoTGBB / azure-iot-edge-hol-linux

IoT Edge Hands On Labs for Ubuntu in Azure
MIT License
11 stars 6 forks source link

Device Twin not working if appending GatewayHostName in connection string #4

Closed pratson20 closed 5 years ago

pratson20 commented 5 years ago

Hi,

I am using transparent gateway implementation with Azure IoT Edge for one of our client. Transparent gateway is reading data over serial and passing the data to Azure Edge Hub using ';GatewayHostName=mygateway.local'. I am able to get data on Edge module.

But i have implemented Device twin on transparent gateway. Invoking method on Azure platform and receiving on transparent gateway. I am able to invoke method using device twin on leaf device and able to report properties back, if i don't append ';GatewayHostName=mygateway.local' with connection string.

If i append ';GatewayHostName=mygateway.local' with connection string then i can invoke method ~one or two times max during the start of script. Later it never get invoked. Using below link for implementation- https://github.com/AzureIoTGBB/azure-iot-edge-hol-linux/tree/master/module2

Python Code is not working in the above link. Can you please help me on this.

Regards, Prateek

stevebus commented 5 years ago

sorry for the delayed response as github is not notifying us of new issues... Is this still a problem? have you tried it again since you opened the issue?

pratson20 commented 5 years ago

@stevebus I am still seeing this issue but found one workaround for same. It works fine few time in start of application but later when we try to update desired property through azure portal from in direct method section. Reported property don't get trigger in pythoan application.

Solved this issue by creating two instance of iothubClient. e.g-

connection_string = "; GatewayHostName=mygateway.local" CONNECTION_STRING = ""

iotHubClient = IoTHubClient(connection_string, protocol) iotHubClient_twin = IoTHubClient(CONNECTION_STRING, protocol)

iotHubClient_twin.set_device_twin_callback(device_twin_callback, 0) iotHubClient_twin.set_device_method_callback(device_method_callback, 0) iotHubClient_twin.set_message_callback(receive_message_callback, 0)

iotHubClient --> this is using to send data to edgeHub.

Using below tutorial- https://github.com/AzureIoTGBB/azure-iot-edge-hol-linux/blob/master/module2/iotdevice.py

Can you help me to resolve this.

stevebus commented 5 years ago

I can see if I can duplicate the error... you should not have to have two instances of the iothubClient... I don't understand this sentence...

"we try to update desired property through azure portal from in direct method section"

desired properties and the device twins are different than direct methods.. which one is causing the issue? can you give a little more detail on how to duplicate the issue?