FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
04-18-2023 11:14 AM
I use the OPC UA Client App. My OPC UA Server is sometimes down during the day.
When the server is down the client App stays disconnected even when the server is up and running again.
Is there a possibility to let the Client App reconnecting until it is connected again without stopping it?
Solved! Go to Solution.
04-18-2023 01:19 PM
Hello jacare,
unfortunately there is currently no way to do an automatic reconnect of the client. It is a planned for the future.
Right now the application needs to take care about the state. In case of disconnect it must call the connect again.
Regards
06-05-2023 08:19 AM
Good morning @jacaré,
we have the same situation as described in your post. We are going to use the NodeRed App to work with a flow which re-establishes a new connection in case the device is switched off. Therefore you can use an inject node to realise it. Let me know if you need further information. Then I could post the node-red flow to you.
BR Markus
06-05-2023 02:35 PM
This sounds great @leonberger-m, please post your solution here.
06-05-2023 03:49 PM
Hi @jacaré
please find enclosed the flow I am currently using. First I used the Ctrlx subscription node to trigger the state. Meanwhile we have switched to an inject node with an initial start + interval. This prevents if machine is switched off that there will be no reconnect after powering on the machine.
Currently we are using 15 seconds. You only have to change the READ node to your own OPC UA client state.
JSON Flow to import to your node red:
[
{
"id": "f4f323db.8181f8",
"type": "tab",
"label": "01_Initial: Establish OPC-UA Connection",
"disabled": false,
"info": ""
},
{
"id": "95eedbc4.8f71f",
"type": "debug",
"z": "f4f323db.8181f8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1130,
"y": 100,
"wires": []
},
{
"id": "8e7e0c8e.d42da8",
"type": "switch",
"z": "f4f323db.8181f8",
"name": "Switch",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "{\"state\":\"CONNECTED\"}",
"vt": "str"
},
{
"t": "eq",
"v": "{\"state\":\"DISCONNECTED\"}",
"vt": "str"
}
],
"checkall": "true",
"repair": true,
"outputs": 2,
"x": 910,
"y": 140,
"wires": [
[
"95eedbc4.8f71f"
],
[
"c809905d.49f848"
]
]
},
{
"id": "bc59e2fa.e7f1a",
"type": "json",
"z": "f4f323db.8181f8",
"name": "JSON to String",
"property": "payload",
"action": "",
"pretty": false,
"x": 740,
"y": 140,
"wires": [
[
"8e7e0c8e.d42da8"
]
]
},
{
"id": "610fa792.374e8",
"type": "ctrlx-datalayer-request",
"z": "f4f323db.8181f8",
"device": "3b393ef1.2b322a",
"method": "WRITE",
"path": "opcuaclient/Bihler GRM-NC/connect",
"payloadFormat": "value_type",
"name": "Connect OPC UA Client",
"x": 1370,
"y": 160,
"wires": [
[]
]
},
{
"id": "c809905d.49f848",
"type": "change",
"z": "f4f323db.8181f8",
"name": "Clear msg.payload",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1130,
"y": 160,
"wires": [
[
"610fa792.374e8"
]
]
},
{
"id": "625a117d.50dbe8",
"type": "comment",
"z": "f4f323db.8181f8",
"name": "JSON to String",
"info": "This Node converts the JSON Object to a string",
"x": 740,
"y": 100,
"wires": []
},
{
"id": "7399ec56.b47b34",
"type": "comment",
"z": "f4f323db.8181f8",
"name": "Switch",
"info": "This Node makes a switch case wehther the OPC UA Client is connected or not",
"x": 910,
"y": 100,
"wires": []
},
{
"id": "d5ff7bd5.a031c8",
"type": "comment",
"z": "f4f323db.8181f8",
"name": "Clear msg.payload",
"info": "This Node is the not connected case of the switch before and clears the msg object of the flow, because in the next coming node, a write function to the data laye node \"opcuaclient/client1/connect\" must be performed to connet the OPC UA Client the the configured OPC UA Server ",
"x": 1130,
"y": 200,
"wires": []
},
{
"id": "714985f4.0dde1c",
"type": "comment",
"z": "f4f323db.8181f8",
"name": "Connect OPC UA Client",
"info": "A write command is performed to the data layer path \"opcuaclient/client1/connect\" to do a connection to the configured OPC UA Server",
"x": 1360,
"y": 120,
"wires": []
},
{
"id": "c2fc2f58b41274b3",
"type": "inject",
"z": "f4f323db.8181f8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "15",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 140,
"wires": [
[
"315932cef7469ad4"
]
]
},
{
"id": "315932cef7469ad4",
"type": "ctrlx-datalayer-request",
"z": "f4f323db.8181f8",
"device": "3b393ef1.2b322a",
"method": "READ",
"path": "opcuaclient/Bihler GRM-NC/state",
"payloadFormat": "value",
"name": "",
"x": 420,
"y": 140,
"wires": [
[
"bc59e2fa.e7f1a"
]
]
},
{
"id": "3934107e59bf377b",
"type": "comment",
"z": "f4f323db.8181f8",
"name": "Inject to verify Status of OPC UA Client",
"info": "An initial inject is triggered.\nAfter that an interval is used to verify\nthe connection status. ",
"x": 210,
"y": 100,
"wires": []
},
{
"id": "3b393ef1.2b322a",
"type": "ctrlx-config",
"name": "ctrlX-bihler1000093",
"hostname": "localhost",
"debug": false
}
]