# Node-RED: Modify node-red-contrib-opcua keepSessionAlive

**URL:** <https://discourse.nodered.org/t/node-red-modify-node-red-contrib-opcua-keepsessionalive/59995>\
**Category:** General\
**Created:** [17 March 2022 15:54 UTC](https://discourse.nodered.org/t/node-red-modify-node-red-contrib-opcua-keepsessionalive/59995 "2022-03-17T15:54:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marek](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@Marek](https://discourse.nodered.org/u/Marek)\
**Post date:** [17 March 2022 15:54 UTC](https://discourse.nodered.org/t/node-red-modify-node-red-contrib-opcua-keepsessionalive/59995/1 "2022-03-17T15:54:22Z")

</div>

I am using Node-RED for communication with OPC UA Server. I installed the node-red-contrib-opcua Node for this purpose. Everything is working fine, but in some cases, I would like to change the OpcUa-Client **keepSessionAlive** property to **false**. Default is true. I did not find it in the node property window. Is there a solution for it?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1c2739e3dbf30873ada6fb746d9c0f9eaa51baed.png)

```auto
[{"id":"29c4b9f87fcbed0a","type":"OpcUa-Item","z":"4566de58de158f7c","item":"ns=3;s=\"DB\".\"BadParts\"","datatype":"String","value":"","name":"BadParts","x":1180,"y":920,"wires":[["9eaf1c412227d061"]]},{"id":"9eaf1c412227d061","type":"OpcUa-Client","z":"4566de58de158f7c","endpoint":"ac342db8.435e1","action":"read","deadbandtype":"a","deadbandvalue":1,"time":10,"timeUnit":"s","certificate":"n","localfile":"","localkeyfile":"","securitymode":"None","securitypolicy":"None","folderName4PKI":"","name":"OPC UA","x":1370,"y":920,"wires":[["4e79b81b818bf8f2"]]},{"id":"4e79b81b818bf8f2","type":"debug","z":"4566de58de158f7c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1530,"y":920,"wires":[]},{"id":"38cd6b7326408150","type":"inject","z":"4566de58de158f7c","name":"","props":[{"p":"payload"},{"p":"keepSessionAlive","v":"false","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":970,"y":920,"wires":[["29c4b9f87fcbed0a"]]},{"id":"ac342db8.435e1","type":"OpcUa-Endpoint","endpoint":"opc.tcp://192.168.0.16:4840","secpol":"None","secmode":"None","login":false}]

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/0/107e28fd31b4d311bfdf5300ca000ff2f6cca7dd.png)

---

<div class="post-metadata">

**Author:** ![mikakaraila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikakaraila/32/37496_2.png) [@mikakaraila](https://discourse.nodered.org/u/mikakaraila)\
**Post date:** [23 March 2022 20:50 UTC](https://discourse.nodered.org/t/node-red-modify-node-red-contrib-opcua-keepsessionalive/59995/2 "2022-03-23T20:50:05Z")

</div>

I can add it.. just new feature that will help perhaps sometimes embedded servers can provide just up to 5 open sessions.

---

<div class="post-metadata">

**Author:** ![Marek](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@Marek](https://discourse.nodered.org/u/Marek)\
**Post date:** [24 March 2022 08:29 UTC](https://discourse.nodered.org/t/node-red-modify-node-red-contrib-opcua-keepsessionalive/59995/3 "2022-03-24T08:29:14Z")

</div>

Hello @mikakaraila,  
yes, this is exactly my case. On the other side is a small OPC UA Server with a strict open session limit.  
I new feature will be great.  
Thank you for your help!

---

<div class="post-metadata">

**Author:** ![mikakaraila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikakaraila/32/37496_2.png) [@mikakaraila](https://discourse.nodered.org/u/mikakaraila)\
**Post date:** [19 April 2022 18:47 UTC](https://discourse.nodered.org/t/node-red-modify-node-red-contrib-opcua-keepsessionalive/59995/4 "2022-04-19T18:47:15Z")

</div>

There was similar kind of problem, one solution is to use one client node and then msg.action to read/write etc. so it uses same session for everything.  
Look example in the issue: [Connection Node-Red with S7 - Error-BadTooManySessions · Issue #428 · mikakaraila/node-red-contrib-opcua · GitHub](https://github.com/mikakaraila/node-red-contrib-opcua/issues/428)

---

<div class="post-metadata">

**Author:** ![Marek](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@Marek](https://discourse.nodered.org/u/Marek)\
**Post date:** [20 April 2022 08:59 UTC](https://discourse.nodered.org/t/node-red-modify-node-red-contrib-opcua-keepsessionalive/59995/5 "2022-04-20T08:59:28Z")

</div>

Hello @mikakaraila,  
thanks a lot for the link.  
I am also using one OPC UA Client for multiple jobs. This is working very well, if you have one flow. As soon as you begin with multiple sub-flows with theirs own OPC UA communication, you will need additional OPC UA Clients. Therefore, I see a keepSessionAlive boolean property practical. Some values are also read/written only sometimes and there is no need to hold the session alive.

---

<div class="post-metadata">

**Author:** ![MountainKing91](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mountainking91/32/59516_2.png) [@MountainKing91](https://discourse.nodered.org/u/MountainKing91)\
**Post date:** [20 April 2022 10:58 UTC](https://discourse.nodered.org/t/node-red-modify-node-red-contrib-opcua-keepsessionalive/59995/6 "2022-04-20T10:58:37Z")

</div>

That would be a really nice feature to have; most PLCs allow a small number of client sessions at the same time.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [19 June 2022 10:58 UTC](https://discourse.nodered.org/t/node-red-modify-node-red-contrib-opcua-keepsessionalive/59995/7 "2022-06-19T10:58:53Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
