OS, version, SKU and CPU architecture used: linux arm32v7hf , iot edge rev 9161dc8eb743c1e839cc7fec07ad3e7df085a42f
Application's .NET Target Framework : core 3.1
Are my obsevations correct? Not sure if this is the right place to submit the issue, but here goes.
I use Microsoft.Azure.Devices.Client 1.29-preview-004.
Works connecting directly to IoT Hub module connection string, but if
IOTEDGE_GATEWAYHOSTNAME is specified, it connects through edgeHub and it doesn't seem to work.
var client = ServiceClient.CreateFromConnectionString(_config["IotHubConnectionString"]);
...
await _client.SendAsync(deviceId, "myModule", message);
Nothing is received so no log :)
AB#7241616
@emilm
Can you explain the scenario that you are trying to implement? From the sample code above, you are creating a service client instance, and using it to send cloud-to-device messages. I assume that the initialization of your module myModule client is the one that you are facing issues with?
If using the CreateFromEnvironmentAsync option for module client initialization, can you confirm that you have the required environmental variables set: https://github.com/Azure/azure-iot-sdk-csharp/blob/master/iothub/device/src/Edge/EdgeModuleClientFactory.cs#L79?. Also, do you see this behavior only over a particular protocol (amqp vs mqtt)?
Hello and thank you! Someone will interact with my device. But it has to ask the server something. Therefore I need to implement a request / response pattern from module to cloud / IoT edge. So I need a "cloud to module" response.
So I create my moduleclient in java
this.client = ModuleClient.createFromEnvironment(IotHubClientProtocol.AMQPS);
env:
HOSTNAME=myhost
IOTEDGE_MODULEID=mymodule
IOTEDGE_GATEWAYHOSTNAME=myhost
RuntimeLogLevel=Information
IOTEDGE_WORKLOADURI=unix:///var/run/iotedge/workload.sock
TERM=xterm
SHLVL=1
IOTEDGE_APIVERSION=2019-11-05
IOTEDGE_AUTHSCHEME=sasToken
IOTEDGE_MODULEGENERATIONID=redacted_
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/bin
IOTEDGE_DEVICEID=
IOTEDGE_IOTHUBHOSTNAME=_redacted_.azure-devices.net
_=/usr/bin/printenv
I tried both AMQP and MQTT on both sides.
Thanks for the information @emilm ; we'll investigate this.
In the Java SDK, there is a check that makes a module client only subscribe to devicebound messages if it isn't connecting to an Edgehub. Is it possible the C# SDK does something similar?
I use the Java library on the client side. Is there a way to log that the edgeHub receives a message to a module but fails to relay it to the correct module?
Thanks!
I switched to mqtt WS but no difference
_Update #1_
I use 1.19.0 of the library. trying an upgrade to 1.22 .
_Update 2_
Same result
In the Java SDK, there is a check that makes a module client only subscribe to devicebound messages if it isn't connecting to an Edgehub. Is it possible the C# SDK does something similar?
So mine does connect to edgehub. Should I try to drop GATEWAY_HOSTNAME and bypass edgeHub to make it work, or is this supposed to work with edgeHub?
So @emilm , are you using the C# client library to send the cloud to device message from the service, but the java client library to receive the messages on a module client instance?
So @emilm , are you using the C# client library to send the cloud to device message from the service, but the java client library to receive the messages on a module client instance?
Correct! I suspect there's something with edgeHub
@timtay-microsoft You did mention that the java client subscribes to devicebound messages only if it isn't connecting to an Edgehub. Do you have additional context on why that is?
It might also be relevant here to differentiate between device bound messages and events, when talking about device client message subscription vs edge module event subscription.
I'm not entirely sure that edgehub supports routing cloud to device messages to modules. I'd bring this question to @varunpuranik
If it does, then the Java SDK just needs to subscribe to the devicebound messages topic regardless of if it is connecting to IoT Hub or Edgehub
I have confirmed offline that edgehub does _not_ support cloud to device messages to modules. So this issue is by design. As such, I'm closing this issue. Feel free to bring up this as a feature request in the edgehub github repo, though
@abhipsaMisra, @emilm, @timtay-microsoft, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey
Most helpful comment
I'm not entirely sure that edgehub supports routing cloud to device messages to modules. I'd bring this question to @varunpuranik
If it does, then the Java SDK just needs to subscribe to the devicebound messages topic regardless of if it is connecting to IoT Hub or Edgehub