Closed shaneholder closed 3 years ago
@shaneholder Are you saying that the method invocation worked and the c2d did not?
@shaneholder I'm curious if you change
client.on('inputMessage', (m) =>{})
to
client.on('message', (m) =>{})
are you communicating IoT Hub to Module Client or Edge Hub to Module Client? It looks like with a service client set up in C# you're communicating directly
Service Client ----> IoT Hub ----> Module Client
@anthonyvercolano
Yes, that is what I experienced, c2d messages would not be received by the client but c2d methods would. I did see the C2D message show up in MQTT on the client, but it just did not match the topic.
@YoDaMa
My scenario is regular IOT not IOT Edge or Hub. I'll see if I can setup the test again and find out.
I also find it interesting that in Azure IoT Explorer and the Azure IOT Portal that you can send a Message to the Device, however this option is not offered on Modules, is that just a feature that needs to be added to the portal/IoT Explorer or are we not supposed to send messages to Modules.
As a user I don't (yet) see a distinction in purpose between the Device and a Module. I am building a collection of services that will work together on a single piece of hardware so I want them to all have the same DeviceId however I want them to act as independent units so I'm creating Modules so I can get a different connection string and not run into the issues with having multiple connections for MQTT.
Perhaps I'm not thinking about Modules correctly?
Regards, Shane
I put together a gitrepo to demonstrate the issue I am seeing
https://github.com/shaneholder/iotDeviceMessageIssues
Hopefully this will illustrate the problem.
@shaneholder replying in the other thread, since your questions are converging. https://github.com/Azure/azure-iot-sdk-node/issues/1016
closing this issue since it's being addressed in a different thread.
Hello,
"name": "azure-iot-device" "version": "1.17.4"
I am attempting to send a message from a C# process to a NodeJS ModuleClient which uses the MQTT transport.
This is the relevant C# code that is sending the message.
A corresponding C# client can receive the message with:
I am attempting to receive the message in Node using:
I have turned on debugging
And I am seeing that the message I am sending is making it to the MQTT transport layer but is not matching any of the provided _topics.
The topic being received is:
I am also sending a command from the C# process which is received by the node process.
Receiving code:
I guess my question is how can I send a C2D to a ModuleClient so that it can be received?
In my debugging it seemed that the message topic matched the else condition around mqtt.js:766 so I commented out the else condition so that the message property would be added to _topics which matched. I then found that when the C2D handler was run an emitter was fired with 'message' which was not emitted by module_client.js so I just replicated the inputMessage code in module_client.js and sure enough I could now catch a 'message' in my node process code. I'm sure this is not the correct behavior but I just wanted to report what I was able to successfully achieve.
Thanks, Shane