Azure / azure-iot-sdk-node

A Node.js SDK for connecting devices to Microsoft Azure IoT services
https://docs.microsoft.com/en-us/azure/iot-hub/
Other
261 stars 226 forks source link

node-red: Multiple Iot Hub nodes all use the last connection string entered #25

Closed beneuto closed 7 years ago

beneuto commented 7 years ago

Description of the issue:

I have 2 Azure IoT Hub nodes, 1 per node-red tab. The intention is to write to these using 2 different connection strings (i.e. represented as 2 different devices).
However, both nodes will use whatever the last connection string deployed was. In other words it is possible to connect to IoT Hub as 1 device only within a single node-red instance.

Context

pierreca commented 7 years ago

Proposed fix in this branch: https://github.com/Azure/azure-iot-sdk-node/tree/fix-25 I'll have it reviewed by the team and checked in, then it'll be available with our next release (next week)

pierreca commented 7 years ago

Just confirming: the fix has been checked into the master branch and will be part of the next release. We'll close the issue when the new package is out.

pierreca commented 7 years ago

Published v0.1.9 with the fix

beneuto commented 7 years ago

Thanks for the quick work, however it is not quite fixed.

Now the UI accepts and shows a different connection string for each IoT Hub node, but the actual connections are still being made through one of them only.

pierreca commented 7 years ago

Reopening. can you share your flow(s) and the way you listen to messages? I did test the whole end-to-end thing and it worked fine. I'm curious to see what I missed.

pierreca commented 7 years ago

Also, I'd like to state right here that while we do have a plan for better support of node-red, we simply don't have the resources to put it in action right now. This package was developed as a sample at a time where node-red didn't have nearly as much traction or documentation on best practices, and as such doesn't follow the conventions that are now recommended.

When we get to executing on that plan, the next generation of nodes that we ship will have nothing to do with the current implementation and there will be breaking changes.

So, unless you're running quick tests and home experiments, if you're thinking of going to production with node-red, I'd strongly recommend looking at building your own packages for now. The thing we have out there is, quite simply, not up to snuff. I'm more than willing to look into fixing it, but I also have to be realistic as to its state and its future.

pierreca commented 7 years ago

@beneuto Hi, I tested again the new version of the node successfully. I did run into something weird though: Apparently when a node is copied from one flow to another, it copies its "instance", so basically, that same node is running in both flows. Could it be that you copy pasted the IoT Hub node?

If I drag and drop a new node from the palette in each flow, it works fine. Can you confirm that?

beneuto commented 7 years ago

It is very likely that I cut and pasted the nodes.

I have deleted the nodes, redeployed, uninstalled the package, reinstalled and re-added each node and deployed one at a time. So far it seems to be working!

Thanks for looking into it.