cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

OPC UA Client reconnect

OPC UA Client reconnect

jacaré
Long-established Member

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?

4 REPLIES 4

DevME
Member

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

leonberger-m
Established Member

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 

jacaré
Long-established Member

This sounds great @leonberger-m,  please post your solution here.

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. 

leonbergerm_1-1685972888367.png

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
}
]

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist