Neil Pate Posted June 13, 2020 Report Share Posted June 13, 2020 (edited) Hi, I am trying to send a simple message to an Azure IoT hub. I am pretty new to all this, but have followed a few tutorials and Pluralsight courses and can successfully send a message from VS Code to my hub. What I have not been able to do yet is send a message using LabVIEW. I have tried several different MQTT libraries, without any success. Has anyone done this kind of thing before and can offer guidance on which toolkit they used? I am using VSCode to generate the SAS token and using that as the password. Edit: I have been able to send some messages using simple C# code, this code works fine. Edited June 13, 2020 by Neil Pate Quote Link to comment
Mads Posted June 13, 2020 Report Share Posted June 13, 2020 (edited) I have successfully used (unsecure) MQTT for LabVIEW, I have not tried it with the Azure IoT broker though. With this LabVIEW implementation for example: https://github.com/cowen71/mqtt-LabVIEW. The connection settings just had to be reconfigured slightly to get the link up and running. Here is a setup that works to connect to adafruit.io....you just need to change the user account and feed name of course, and the password (intentionally cropped out here): You may also need to open the firewall...In my case it allowed the connection, but blocked everything afterwards (producing error 66). I have not been able to use TLS with any of LabVIEW implementations though, but perhaps that can be remedied more easily now that TLS is supported in LabVIEW 2020... Edited June 13, 2020 by Mads Quote Link to comment
Neil Pate Posted June 13, 2020 Author Report Share Posted June 13, 2020 (edited) Thanks, I am actually already about half-way through the 2020 installation so I can check out the TLS stuff. That library you mentioned is what I am using, I did try modifying all the settings that seem sensible (for example Azure IoT hub uses port 8883) but it still does not work. Actually the connect seems to work, and the publish does not give any errors but no data appears in my hub. I am still very much a newbie in Azure IoT so there is a lot to learn for me. Edited June 13, 2020 by Neil Pate Quote Link to comment
Francois Normandin Posted June 13, 2020 Report Share Posted June 13, 2020 Just a thought. Have you verified which version of MQTT is supported on Azure? MQTT 5 is most recent, and although MQTT 3.1 is normally supported by brokers, Azure IoT hub is not a fully-compatible MQTT broker. There might be restrictions on QoS, will messages or even TCP vs Web Sockets... Quote Link to comment
Francois Normandin Posted June 13, 2020 Report Share Posted June 13, 2020 I usually run my code against test.mosquitto.org Quote Link to comment
Neil Pate Posted June 13, 2020 Author Report Share Posted June 13, 2020 Thank Francois. I believe Azure does support 3.1 but I cannot recall where I saw this info. I think the problem is the missing TLS which I am now digging into. Now I am down a rabbit hole of security concepts and terminology that I have only ever had a passing interest in. TLS, X.509, primary thumbprints 🤯 Quote Link to comment
Neil Pate Posted June 13, 2020 Author Report Share Posted June 13, 2020 Wow, 2020 could really do with an example of how to use TLS! Quote Link to comment
Francois Normandin Posted June 13, 2020 Report Share Posted June 13, 2020 If it's a commercial project and you're on a deadline, you can check Wireflow's MQTT client. It ain't free, but supports TLS. http://sine.ni.com/nips/cds/view/p/lang/fr/nid/213501 Quote Link to comment
Neil Pate Posted June 13, 2020 Author Report Share Posted June 13, 2020 1 minute ago, Francois Normandin said: If it's a commercial project and you're on a deadline, you can check Wireflow's MQTT client. It ain't free, but supports TLS. http://sine.ni.com/nips/cds/view/p/lang/fr/nid/213501 Yes I am more than happy to pay for a commercial toolkit, but I did try this out also and it did not connect either. I will get in touch with them I think 🙂 1 Quote Link to comment
Mads Posted June 14, 2020 Report Share Posted June 14, 2020 Port 8883 is usually used for TLS (1883 for non-TLS). There are a couple of examples of how to use TLS in 2020, if you search for TLS in the examples finder: 1 Quote Link to comment
Neil Pate Posted June 14, 2020 Author Report Share Posted June 14, 2020 1 hour ago, Mads said: Port 8883 is usually used for TLS (1883 for non-TLS). There are a couple of examples of how to use TLS in 2020, if you search for TLS in the examples finder: Thanks, I did actually search but did not press enter and just bailed when the Keywords list was empty! Quote Link to comment
Neil Pate Posted June 14, 2020 Author Report Share Posted June 14, 2020 (edited) @mads Awesome, it works! Thank you for your suggestion. I did not realise TLS could be done "simply", I was messing around with certificates and stuff and getting nowhere! Edited June 14, 2020 by Neil Pate Quote Link to comment
Neil Pate Posted June 14, 2020 Author Report Share Posted June 14, 2020 This is the only change I made to the MQTT library. Simples 🙂 1 Quote Link to comment
Francois Normandin Posted June 14, 2020 Report Share Posted June 14, 2020 11 hours ago, Neil Pate said: This is the only change I made to the MQTT library. Simples 🙂 I had not realized either it was so simple to add TLS. I didn't plan to upgrade my broker to 2020, but multiplatform TLS is tempting. (shameless plug for my project: https://github.com/LabVIEW-Open-Source/LV-MQTT-Broker) Quote Link to comment
Neil Pate Posted June 16, 2020 Author Report Share Posted June 16, 2020 (edited) WOOT! Just tested this MQQT library running on a simulated cRIO in a VM and it also works and can talk to my Azure IoT hub 🤩 Edited June 16, 2020 by Neil Pate 1 Quote Link to comment
Neil Pate Posted June 16, 2020 Author Report Share Posted June 16, 2020 (edited) On 6/15/2020 at 1:54 AM, Francois Normandin said: I had not realized either it was so simple to add TLS. I didn't plan to upgrade my broker to 2020, but multiplatform TLS is tempting. (shameless plug for my project: https://github.com/LabVIEW-Open-Source/LV-MQTT-Broker) I did look at your Github page but did not try your code as I though it was the broker only. However upon closer examination I see it does include a client also. Would it be of interest to you to see if I can get it connecting to my Azue IoT hub? Edit: there seems to be an error in the project, the two Destroy.vi are not there. Removing them manually seems to fix the Test Server e I did try make the TLS changes and connect with sensible parameters but it did not seem to work. I can try again tomorrow if you like, otherwise I am probably going to park this here for now as I have a working solution with the other MQTT library. Edited June 16, 2020 by Neil Pate Quote Link to comment
Francois Normandin Posted June 19, 2020 Report Share Posted June 19, 2020 (edited) @Neil Pate I thought I had fixed this bug. It dates from my NIWeek 2019 demo when I made a last minute change from "Destroy" public method to "onDestroy" protected method. You see what happens when you do a TDD project and you skip the tests "JUST ONCE" because you're in a hurry and the boss wants this code deployed ASAP??? Hahaha! I'll do a fix this weekend... Edit: Was fixed in the Develop branch... I'll test, bring to master branch, build and release a new package. Edited June 19, 2020 by Francois Normandin 1 Quote Link to comment
Francois Normandin Posted June 20, 2020 Report Share Posted June 20, 2020 (edited) fixed and pre-released as 1.0.2 build. pushed to default branch https://github.com/LabVIEW-Open-Source/LV-MQTT-Broker/releases/tag/1.0.2 Edited June 20, 2020 by Francois Normandin Quote Link to comment
Neil Pate Posted July 5, 2020 Author Report Share Posted July 5, 2020 Quick update. I can send data from my cRIO to an Azure IoT hub, from there pass it to an Azure Streaming Analytics job which pumps the data into an Azure SQL DB and also to a Power BI Dashboard. The pieces of the puzzle are starting to fall into place 🙂 1 Quote Link to comment
JorgeinSD Posted July 8, 2020 Report Share Posted July 8, 2020 Hi guys, So there's no way I could use either library (original or Francois') in LabVIEW 2018 to send data to an Azure IoT hub? - I read a post that someone used .NET constructors to a TLS 1.2 DLL but it sounds like a minefield. Jorge Quote Link to comment
Breizh_Instruments Posted September 22, 2020 Report Share Posted September 22, 2020 Hello everybody, Thank you for this very interesting topic. I need to connect as a client to a broker with a certificate. Is there someone that use the LV 2020 TLS with this client LV-MQTT ? Quote Link to comment
Jordan Kuehn Posted September 22, 2020 Report Share Posted September 22, 2020 4 hours ago, Breizh_Instruments said: Hello everybody, Thank you for this very interesting topic. I need to connect as a client to a broker with a certificate. Is there someone that use the LV 2020 TLS with this client LV-MQTT ? I have not used this particular client, but have done something similar with AWS and MQTT and a different client. I wound up stripping out all the OpenSSL stuff for the new native LabVIEW tools. Here is what worked for me during some initial tests. It may not be perfect, but hopefully it's a start at least. After that it's regular TCP Read/Write. Quote Link to comment
Steve Drouilhet Posted October 2, 2020 Report Share Posted October 2, 2020 @Jordan Kuehn Thanks for posting regarding your TLS implementation with MQTT. What MQTT client were you using in LabVIEW? Thanks. Quote Link to comment
Jordan Kuehn Posted October 3, 2020 Report Share Posted October 3, 2020 @Steve Drouilhet No problem. I believe it was this toolkit: https://github.com/Indie-Energy/AWS-IoT-RESTful and the license is pretty wide open I believe. If I have a chance I'll see if I can pack it up and contribute to the project on the github. I'm also using the WireFlow toolkit (paid) for some MQTT projects with a broker that I've set up. I was initially drawn to the Indie-Energy one even though I have a WF toolkit license since it was more plug and play for AWS. I do think now after learning more about the AWS IoT stuff that either will work, but also that I don't want to work with AWS IoT if I can help it. Note, the WF toolkit does not use the native LV2020 implementation and they do not have plans to do so. The reason I replaced the IE toolkit TLS code is because I had issues on Linux RT and that fixed it. I have not had issues in general with WF on RT, but I'm not using TLS in that application (yet). 1 Quote Link to comment
UncleFungus46 Posted November 20, 2020 Report Share Posted November 20, 2020 (edited) Hi Neil. Long time no see. I am trying to do something similar to what you have done above - I have my Azure hub set up and can talk to it via my Beaglebone ok (trying to open the door of my Chicken Coop). What I'm not getting is where the Primary Key/Connection String gets inserted using the MQTT (Cowen71). I seem to connect to the hub ok, just not the device. Can you offer any assistance? Thanks, Rob (FIF1) Edited November 20, 2020 by UncleFungus46 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.