Aws IoT PLCNext connector

I am trying to use the Aws IoT Connector from the store, but upon connecting to the MQTT server it is throwing a SIGSEGV. Where can I find some additional logging / information what could have caused this error ?

19.03.20 10:17:34.910 PxceTcs.Mqtt.GdsConnectorComponent INFO - Loaded configuration from file: /opt/plcnext/projects/MqttClient/mqt t_gds.settings.json 19.03.20 10:17:34.913 PxceTcs.Mqtt.GdsConnectorComponent INFO - Loaded configuration schema. 19.03.20 10:17:34.922 PxceTcs.Mqtt.GdsConnectorComponent INFO - Configuration is valid. 19.03.20 10:17:34.925 PxceTcs.Mqtt.GdsConnectorComponent INFO - No status port has been specified. 19.03.20 10:17:34.926 PxceTcs.Mqtt.GdsConnectorComponent INFO - No reconnect port has been specified. 19.03.20 10:17:34.933 PxceTcs.Mqtt.GdsConnectorComponent INFO - Created MQTT Client with ID: 37586 19.03.20 10:17:34.934 PxceTcs.Mqtt.GdsConnectorComponent INFO - No MQTT Last Will Options provided. Defaults will be used. 19.03.20 10:17:34.936 PxceTcs.MqttClient.MqttClientManager INFO - Connecting to MQTT server 19.03.20 10:17:35.082 Arp.System.Commons.Runtime.SignalHandler FATAL - Signal SIGSEGV occured.

I also have the impression that this error prevented critical services to start on the PLC, as I was unable to connect with PLCNext Engineer anymore. (after deleting the " /opt/plcnext/projects/MqttClient/mqtt_gds.settings.json" file to prevent the mqtt component to load I was able to connect again using PLCNext Engineer)

Hello, I am assuming that you are using a recent firmware version. The documentation for this app is not 100% correct - it states that it is compatible with firmware version 2019.3 or later, but there was a breaking change in a recent firmware version (related to OpenSSL) that is probably causing the problem you are seeing. Until we can update this app, there are a couple of work-arounds: 1) You could install firmware version 2019.3 on the PLC (probably not ideal), or 2) You can use the MQTT Client app from the store instead. This has been updated for the latest firmware, and should not have the same issue as the AWS app. You can use the same .json configuration file with the MQTT Client app, that you are using with the AWS app. If you decide to try the MQTT Client app, please uninstall the AWS app first. The reason that you cannot connect with PLCnext Engineer, is that the segfault crashes the complete PLCnext runtime application, and this is required for PLCnext Engineer to establish a connection. By deleting the config file, the AWS app stopped “gracefully” before it got to the function that causes the segfault, so the PLCnext runtime and the PLCnext Engineer connection were unaffected. Hope this helps. ~ Martin.

Thx a lot … I will try the MQTT Client app. I am actually looking for a “well architected” solution that will allow us to hookup the PLCNext to AWS IoT . For the POC the use-case is very simple :

                                               * **use-case 1** : Receive a JSON payload (key value pairs) via Aws IoT into the PLCNext that can be deserialized, processed, and used to toggle some digital outputs 
                                                 * example : {"do1":true , "do2":false} is received and toggles digital output 1 to ON and digital output 2 to OFF
                                               * **use-case 2** : Have the PLCNext publish a JSON payload when a digital input changes 
                                                 * example : {"d1": true, "di2": false} is sent when either d1 or d2 changes value, to indicate that digital input 1 is switched ON and digital input 2 is switched OFF.

With “well architected” I mean a solution that Phoenix Contact can consider “solid”, and not something I would hack together using python or something on the PLCNext. As you can see the use-cases are very simple and I would like to make use of existing building blocks as much as possible and don’t want to do a lot of custom development. As there are lots of options and lots of ways to “run” “something” on the PLC I would like to align it with the overal PLCNext architecture and best practices. For the moment I am looking at 2 solutions :
* solution 1 : Creating / Designing an IEC 61131-3 Program with PLCNext Engineer (using 1 of the 4 supported languges)
* solution 2 : Creating a node-red flow that has an AWS IOT connector (off-the-shelf ?) to consume / publish mqtt messages, and hook into the PLC logic / input / outputs / variables / (via OPC-UA ?)
* other supported solutions ?
If you have other guidance regarding the use-cases above I would be happy to hear them Thx a lot.

I’ve been unable to connect to Aws IoT using the MQTT connector. I’m getting the following error :

19.03.20 16:12:33.257 PxceTcs.Mqtt.GdsConnectorComponent INFO - Loaded configuration from file: /opt/plcnext/projects/MqttClient/mqt t_gds.settings.json 19.03.20 16:12:33.260 PxceTcs.Mqtt.GdsConnectorComponent INFO - Loaded configuration schema. 19.03.20 16:12:33.270 PxceTcs.Mqtt.GdsConnectorComponent INFO - Configuration is valid. 19.03.20 16:12:33.273 PxceTcs.Mqtt.GdsConnectorComponent INFO - No status port has been specified. 19.03.20 16:12:33.274 PxceTcs.Mqtt.GdsConnectorComponent INFO - No reconnect port has been specified. 19.03.20 16:12:33.275 PxceTcs.Mqtt.GdsConnectorComponent INFO - No cycle count port has been specified. 19.03.20 16:12:33.282 PxceTcs.Mqtt.GdsConnectorComponent INFO - Created MQTT Client with ID: 14394 19.03.20 16:12:33.283 PxceTcs.Mqtt.GdsConnectorComponent INFO - No MQTT Last Will Options provided. Defaults will be used. 19.03.20 16:12:33.286 PxceTcs.MqttClient.MqttClientManager INFO - Connecting to MQTT server 19.03.20 16:12:33.839 PxceTcs.MqttClient.MqttClientManager ERROR - Exception in operation: Connect(14394, ConnectOptions) 19.03.20 16:12:33.840 PxceTcs.MqttClient.MqttClientManager ERROR - MQTT error [-1]: TCP connect completion failure 19.03.20 16:12:33.841 PxceTcs.Mqtt.GdsConnectorComponent ERROR - Error connecting to MQTT Client 14394 19.03.20 16:12:33.843 PxceTcs.Mqtt.GdsConnectorComponent ERROR - App will NOT START due to previous error. 19.03.20 16:12:33.915 Arp.Device.Interface.Internal.DeviceStatus INFO - CheckHwTask running 19.03.20 16:12:33.917 Arp.Device.Interface.Internal.DeviceStatus INFO - Alloc memory for 2 ports 19.03.20 16:12:33.919 Arp.Device.Interface.Internal.DeviceStatus WARN - SD Card inserted 19.03.20 16:12:35.675 Arp.Services.OpcUAServer.Internal.Config.OpcUAConfigManager INFO - Using the self-signed certificate.

the config file I am using is :

{ “brokers”:[{ “host”: “ssl://a1u42g5r3r0xje-ats.iot.eu-central-1.amazonaws.com:8883”, “client_name”: “plcclient1”, “connect_options”:{ “ssl_options”: { “trust_store”:“/opt/plcnext/projects/MqttClient/AmazonRootCA1.pem”, “key_store”: “/opt/plcnext/projects/MqttClient/df4de6707d-certificate.pem.crt”, “private_key”: “/opt/plcnext/projects/MqttClient/df4de6707d-private.pem.key”, “enable_server_cert_auth”: true } }, “publish_data”:[{ “port” : “Arp.Plc.Eclr/MainInstance.PubMessage”, “qos”: 0, “retained”: false, “topics” :[ “MyPubTopic” ] }], “subscribe_data”:[{ “topic” : “MySubTopic”, “ports” :[ “Arp.Plc.Eclr/MainInstance.SubMessage” ] }] }] }

I can have it connect to my local mqtt broker in the network, but not to a TLS based system like Aws IoT (I am using a simple nodejs client to verify I can connect to Aws IoT using the same certificates and host)

Seems that the will options in the config file is mandatory otherwise the connection fails. I’ve logged an issue for that on github : https://github.com/PLCnext/MqttGdsConnector/issues/9 Think this is a bug as the code seems to be written with the idea that will options are optional.

Now that I can connect to the Aws IoT broker, I wanted to exchange some message so here’s what I did : In my MainInstance program, as described in the docs, I created 2 variables : PubMessage (OUT port) and SubMessage (IN port) Screenshot 2020 03 20 07.33.17 When I run the program I put a new value in the PubMessage variable Screenshot 2020 03 20 07.38.23 And I see the message is set Screenshot 2020 03 20 07.32.54 But on my Aws IoT client I don’t see the message popping up Screenshot 2020 03 20 07.34.10 I don’t know if I need to do any addtional configuration ? For example here do I need to select addtional IN / OUT ports in order for this to work ? Screenshot 2020 03 20 07.45.49 I am using the following config :

{ “brokers”:[{ “host”: “tcp://192.168.0.138:1883”, “client_name”: “plcclient1”, “connect_options”:{ “will_options”:{ “topic”: “last_will_topic”, “payload”: “auf wiedersehen” }, “ssl_options”: { “trust_store”:“/opt/plcnext/projects/MqttClient/AmazonRootCA1.pem”, “key_store”: “/opt/plcnext/projects/MqttClient/df4de6707d-certificate.pem.crt”, “private_key”: “/opt/plcnext/projects/MqttClient/df4de6707d-private.pem.key”, “enable_server_cert_auth”: false } }, “publish_data”:[{ “port” : “Arp.Plc.Eclr/MainInstance.PubMessage”, “qos”: 0, “retained”: false, “topics” :[ “MyPubTopic” ] }], “subscribe_data”:[{ “topic” : “MySubTopic”, “ports” :[ “Arp.Plc.Eclr/MainInstance.SubMessage” ] }] }] }

Any idea what I am missing ?

Hello, Thanks for all the work you put into this!

I think you will have to subscribe the Topic not publis to it to actually see the changes. Your AWS is also Publishing effectivly overriding the content.
As MyPubTopic does not seem to be subscribed anywhere you cant see if it actually is sent … or maybe I am missing that part.

AWS/PLC - Subscribe → MyPubTopic
PLC “some message” -Publish to-> MyPubTopic

Broker MyPubTopic - notifies Subcribers > AWS/PLC get the message.

I am not publishing from AWS, just subscribing to MyPubTopic (the AWS Test Console UI is very confusing as it mixes up publish and subscribe concepts, so the screenshot might be misleading). To be clear, I am using the AWS console to subscribe to MyPubTopic so I can see messages.I am not publishing messages to MyPubTopic in AWS. I assume that it’s the PLC that will do the publishing when the PubMessage variable changes (and I want to see those messages in the AWS Test Console) Likewise, I expect the PLCNext variable to see incoming messages in the SubMessage variable when somebody puts a message on MySubTopic(but that is also not working) Tried to make it more clear on how I interpret it with this picture (perhaps this interpretation is wrong ?): Screenshot 2020 03 20 08.26.15 As a side node : I am doing a POC at the moment as I am excited about the features of hooking up a PLC to IoT constructs like AWS IoT. Feel free to send me an email at davy.dewaele at ixor dot be if you want to discuss this further. We would love to work with you on this and also make it easier for other people to get this stuff up and running. I was thinking about an elaborate blog post with working code / samples that people can more easily deploy.

Seems to be an issue with the MqttClient and AWS combination. With my mosquitto MQTT broker on the network it seems to work. (I can get data in / out the PLC over MQTT) Can you confirm that this component will work with Aws IoT ? I have the AWS - MQTT Client component up and running and it seems to be working fine. The only thing I would like to have some feedback on is this : For the POC that I am doing with PLCNext - AWS, the use-case is very simple :

                                               * **use-case 1** : Receive a JSON payload (key value pairs) via Aws IoT into the PLCNext that can be deserialized, processed, and used to toggle some digital outputs 
                                                 * example : {"do1":true , "do2":false} is received and toggles digital output 1 to ON and digital output 2 to OFF
                                               * **use-case 2** : Have the PLCNext publish a JSON payload when a digital input changes 
                                                 * example : {"d1": true, "di2": false} is sent when either d1 or d2 changes value, to indicate that digital input 1 is switched ON and digital input 2 is switched OFF.

I’m looking to do this using a “well architected” solution that Phoenix Contact can consider “solid”, and not something I would hack together using python or something on the PLCNext. As you can see the use-cases are very simple and I would like to make use of existing building blocks as much as possible and don’t want to do a lot of custom development. As there are lots of options and lots of ways to “run” “something” on the PLC I would like to align it with the overal PLCNext architecture and best practices. For the moment I am looking at 2 solutions :
* solution 1 : Creating / Designing an IEC 61131-3 Program with PLCNext Engineer (using 1 of the 4 supported languges)
* solution 2 : Creating a node-red flow that has an AWS IOT connector (off-the-shelf ?) to consume / publish mqtt messages, and hook into the PLC logic / input / outputs / variables / (via OPC-UA ?)
* other supported solutions ?
If you have other guidance regarding the use-cases above I would be happy to hear them

Hi Davy, Glad to hear that you are making progress with your POC. On your request for feedback - I have asked my colleagues in Phoenix Contact Belgium to contact you. They have good technical knowledge of PLCnext Technology and have already been involved with a good few projects for other Belgian customers. It is worth chatting to those guys when you are planning a PLCnext project. We (at Phoenix Contact HQ) work closely with them and we are happy to offer our advice if/when needed. ~ Martin.