# Error sending OPC UA variable

**URL:** <https://discourse.nodered.org/t/error-sending-opc-ua-variable/8438>\
**Category:** General\
**Created:** [27 February 2019 12:42 UTC](https://discourse.nodered.org/t/error-sending-opc-ua-variable/8438 "2019-02-27T12:42:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike67](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@mike67](https://discourse.nodered.org/u/mike67)\
**Post date:** [27 February 2019 12:42 UTC](https://discourse.nodered.org/t/error-sending-opc-ua-variable/8438/1 "2019-02-27T12:42:27Z")

</div>

Hello  
I use OPCua-iiot contrib to access to OPC UA variables inside an OPC UA server.  
I can read and write with no problem, using the predifined nodes.

But there, i need to use the 'change' node to prepare the content of the msg to be sent to set a value in an OPC UA variable.  
I get the result :"Wrong Inject Type undefined! The msg.injectType has to be write."  
I can't find any expmlaination about this error.

Here is my flow :  
[{"id":"e49844ac.af9d58","type":"change","z":"10110044.30b59","name":"Préparation des datas à envoyer","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"topic":"","nodetype":"inject","injectType":"write","addressSpaceItems":[{"name":"xSend","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xTest","datatypeName":"Boolean"}],"payload":true}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":586.0195388793945,"y":632.0039043426514,"wires":[["a6b3e89a.5f1b48","1b4c06d.0742df9"]]},{"id":"4ba9a4f7.395bbc","type":"OPCUA-IIoT-Response","z":"10110044.30b59","name":"","compressStructure":false,"showStatusActivities":false,"showErrors":false,"activateUnsetFilter":false,"activateFilters":false,"negateFilter":false,"filters":[],"x":1098.01953125,"y":626.0039129257202,"wires":[["d166869f.3d1c58"]]},{"id":"d166869f.3d1c58","type":"debug","z":"10110044.30b59","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1268.01953125,"y":626.0039129257202,"wires":[]},{"id":"c174f2b7.b5c62","type":"inject","z":"10110044.30b59","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":335.8984565734863,"y":621.953145980835,"wires":[["e49844ac.af9d58"]]},{"id":"a6b3e89a.5f1b48","type":"OPCUA-IIoT-Write","z":"10110044.30b59","connector":"21582029.3743a","name":"Envoi datas préparées","justValue":true,"showStatusActivities":true,"showErrors":true,"x":896.0195159912109,"y":632.0038890838623,"wires":[["4ba9a4f7.395bbc"]]},{"id":"1b4c06d.0742df9","type":"debug","z":"10110044.30b59","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":852.89453125,"y":725.6875,"wires":[]},{"id":"21582029.3743a","type":"OPCUA-IIoT-Connector","z":"","discoveryUrl":"","endpoint":"opc.tcp://127.0.0.1:4840","keepSessionAlive":true,"loginEnabled":false,"securityPolicy":"Basic128Rsa15","securityMode":"SIGNANDENCRYPT","name":"LOCAL SERVER","showErrors":true,"individualCerts":false,"publicCertificateFile":"","privateKeyFile":"","defaultSecureTokenLifetime":"","endpointMustExist":false,"autoSelectRightEndpoint":false,"strategyMaxRetry":"","strategyInitialDelay":"","strategyMaxDelay":"","strategyRandomisationFactor":"","requestedSessionTimeout":"","connectionStartDelay":"","reconnectDelay":"","maxBadSessionRequests":"10"}]

I don't think i made an error in the json syntax... so, can anybody help me?  
{  
"topic": "",  
"nodetype": "inject",  
"injectType": "write",  
"addressSpaceItems": [  
{  
"name": "xSend",  
"nodeId": "ns=5;s=Arp.Plc.Eclr/MainInstance.xTest",  
"datatypeName": "Boolean"  
}  
],  
"payload": true  
}

---

<div class="post-metadata">

**Author:** ![mike67](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@mike67](https://discourse.nodered.org/u/mike67)\
**Post date:** [1 March 2019 08:01 UTC](https://discourse.nodered.org/t/error-sending-opc-ua-variable/8438/2 "2019-03-01T08:01:54Z")

</div>

Hi there.  
Nobody could answer?  
Is my request not clear?  
Where is there any detailled explanation about the errors Node-Red nodes return?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [1 March 2019 08:15 UTC](https://discourse.nodered.org/t/error-sending-opc-ua-variable/8438/3 "2019-03-01T08:15:30Z")

</div>

Your flow isn't currently importable.Please read the following post [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506?u=ukmoose) and then edit the above message.

The error comes from the contrib node you are using, you could contact the developer to raise the issue via the nodes github page.

---

<div class="post-metadata">

**Author:** ![mike67](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@mike67](https://discourse.nodered.org/u/mike67)\
**Post date:** [13 March 2019 09:07 UTC](https://discourse.nodered.org/t/error-sending-opc-ua-variable/8438/4 "2019-03-13T09:07:22Z")

</div>

Now, I have fixed the problem by using an other node.  
Here is an example wich send an email when an OPC UA tag 'xSend' is set to TRUE, and it sets the OPC UA tag 'xSent' to true when the mail has been sent.  
xSent returns to False when xSend returns to false.

`[{&quot;id&quot;:&quot;10110044.30b59&quot;,&quot;type&quot;:&quot;tab&quot;,&quot;label&quot;:&quot;Send Mail&quot;,&quot;disabled&quot;:false,&quot;info&quot;:&quot;&quot;},{&quot;id&quot;:&quot;d0cb2109.ab173&quot;,&quot;type&quot;:&quot;OPCUA-IIoT-Inject&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;injectType&quot;:&quot;read&quot;,&quot;payload&quot;:&quot;&quot;,&quot;payloadType&quot;:&quot;date&quot;,&quot;topic&quot;:&quot;&quot;,&quot;repeat&quot;:&quot;5&quot;,&quot;crontab&quot;:&quot;&quot;,&quot;once&quot;:false,&quot;startDelay&quot;:&quot;&quot;,&quot;name&quot;:&quot;Scan xSend ...&quot;,&quot;addressSpaceItems&quot;:[{&quot;name&quot;:&quot;xSend&quot;,&quot;nodeId&quot;:&quot;ns=5;s=Arp.Plc.Eclr/MainInstance.xSend&quot;,&quot;datatypeName&quot;:&quot;&quot;},{&quot;name&quot;:&quot;&quot;,&quot;nodeId&quot;:&quot;ns=5;s=Arp.Plc.Eclr/MainInstance.strText&quot;,&quot;datatypeName&quot;:&quot;&quot;},{&quot;name&quot;:&quot;&quot;,&quot;nodeId&quot;:&quot;ns=5;s=Arp.Plc.Eclr/MainInstance.xSent&quot;,&quot;datatypeName&quot;:&quot;&quot;},{&quot;name&quot;:&quot;&quot;,&quot;nodeId&quot;:&quot;ns=5;s=Arp.Plc.Eclr/MainInstance.strMailTo&quot;,&quot;datatypeName&quot;:&quot;&quot;},{&quot;name&quot;:&quot;&quot;,&quot;nodeId&quot;:&quot;ns=5;s=Arp.Plc.Eclr/MainInstance.strMailCC&quot;,&quot;datatypeName&quot;:&quot;&quot;},{&quot;name&quot;:&quot;&quot;,&quot;nodeId&quot;:&quot;ns=5;s=Arp.Plc.Eclr/MainInstance.strMailBCC&quot;,&quot;datatypeName&quot;:&quot;&quot;}],&quot;x&quot;:236.00001907348633,&quot;y&quot;:248.00000286102295,&quot;wires&quot;:[[&quot;4c0f65aa.553d3c&quot;]]},{&quot;id&quot;:&quot;e3f86348.7ae06&quot;,&quot;type&quot;:&quot;comment&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;Lecture texte à envoyer&quot;,&quot;info&quot;:&quot;&quot;,&quot;x&quot;:202.00001907348633,&quot;y&quot;:70.00000381469727,&quot;wires&quot;:[]},{&quot;id&quot;:&quot;33c9ab4f.6e6904&quot;,&quot;type&quot;:&quot;change&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;copy mail adresses, and strText in Mail&quot;,&quot;rules&quot;:[{&quot;t&quot;:&quot;set&quot;,&quot;p&quot;:&quot;to&quot;,&quot;pt&quot;:&quot;msg&quot;,&quot;to&quot;:&quot;payload[3].value&quot;,&quot;tot&quot;:&quot;msg&quot;},{&quot;t&quot;:&quot;set&quot;,&quot;p&quot;:&quot;cc&quot;,&quot;pt&quot;:&quot;msg&quot;,&quot;to&quot;:&quot;payload[4].value&quot;,&quot;tot&quot;:&quot;msg&quot;},{&quot;t&quot;:&quot;set&quot;,&quot;p&quot;:&quot;bcc&quot;,&quot;pt&quot;:&quot;msg&quot;,&quot;to&quot;:&quot;payload[5].value&quot;,&quot;tot&quot;:&quot;msg&quot;},{&quot;t&quot;:&quot;set&quot;,&quot;p&quot;:&quot;payload&quot;,&quot;pt&quot;:&quot;msg&quot;,&quot;to&quot;:&quot;payload[1].value&quot;,&quot;tot&quot;:&quot;msg&quot;}],&quot;action&quot;:&quot;&quot;,&quot;property&quot;:&quot;&quot;,&quot;from&quot;:&quot;&quot;,&quot;to&quot;:&quot;&quot;,&quot;reg&quot;:false,&quot;x&quot;:1411.00004196167,&quot;y&quot;:245.00001335144043,&quot;wires&quot;:[[&quot;ab1624f6.a3f398&quot;,&quot;7518e5a1.a4f6bc&quot;,&quot;4b371b6a.c3f7c4&quot;]]},{&quot;id&quot;:&quot;ab1624f6.a3f398&quot;,&quot;type&quot;:&quot;e-mail&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;server&quot;:&quot;smtp.gmail.com&quot;,&quot;port&quot;:&quot;465&quot;,&quot;secure&quot;:true,&quot;name&quot;:&quot;&quot;,&quot;dname&quot;:&quot;Sending mail&quot;,&quot;x&quot;:1708.0001945495605,&quot;y&quot;:246.0000286102295,&quot;wires&quot;:[]},{&quot;id&quot;:&quot;4c0f65aa.553d3c&quot;,&quot;type&quot;:&quot;OPCUA-IIoT-Read&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;attributeId&quot;:&quot;13&quot;,&quot;maxAge&quot;:1,&quot;depth&quot;:1,&quot;connector&quot;:&quot;21582029.3743a&quot;,&quot;name&quot;:&quot;... In the local server&quot;,&quot;justValue&quot;:true,&quot;showStatusActivities&quot;:true,&quot;showErrors&quot;:true,&quot;parseStrings&quot;:false,&quot;historyDays&quot;:&quot;&quot;,&quot;x&quot;:442.0000190734863,&quot;y&quot;:247.00000286102295,&quot;wires&quot;:[[&quot;8b5a0cd8.fb222&quot;]]},{&quot;id&quot;:&quot;8b5a0cd8.fb222&quot;,&quot;type&quot;:&quot;OPCUA-IIoT-Response&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;Wait for answer&quot;,&quot;compressStructure&quot;:true,&quot;showStatusActivities&quot;:true,&quot;showErrors&quot;:true,&quot;activateUnsetFilter&quot;:false,&quot;activateFilters&quot;:false,&quot;negateFilter&quot;:false,&quot;filters&quot;:[],&quot;x&quot;:672.0000152587891,&quot;y&quot;:246.00000190734863,&quot;wires&quot;:[[&quot;4abaa77f.5c3dc8&quot;,&quot;7c7aec60.dd4ea4&quot;,&quot;abdef645.a4af28&quot;]]},{&quot;id&quot;:&quot;4abaa77f.5c3dc8&quot;,&quot;type&quot;:&quot;switch&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;Test xSend = true&quot;,&quot;property&quot;:&quot;payload[0].value&quot;,&quot;propertyType&quot;:&quot;msg&quot;,&quot;rules&quot;:[{&quot;t&quot;:&quot;true&quot;}],&quot;checkall&quot;:&quot;true&quot;,&quot;repair&quot;:false,&quot;outputs&quot;:1,&quot;x&quot;:881.0000190734863,&quot;y&quot;:248.00000190734863,&quot;wires&quot;:[[&quot;6198d7d9.ae24f8&quot;]]},{&quot;id&quot;:&quot;7518e5a1.a4f6bc&quot;,&quot;type&quot;:&quot;OPCUA-IIoT-Node&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;injectType&quot;:&quot;write&quot;,&quot;nodeId&quot;:&quot;ns=5;s=Arp.Plc.Eclr/MainInstance.xSent&quot;,&quot;datatype&quot;:&quot;Boolean&quot;,&quot;value&quot;:&quot;true&quot;,&quot;name&quot;:&quot;Send xSent ...&quot;,&quot;topic&quot;:&quot;&quot;,&quot;showErrors&quot;:false,&quot;x&quot;:1713.8868827819824,&quot;y&quot;:302.45704460144043,&quot;wires&quot;:[[&quot;e7f659ad.f856d8&quot;]]},{&quot;id&quot;:&quot;e7f659ad.f856d8&quot;,&quot;type&quot;:&quot;OPCUA-IIoT-Write&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;connector&quot;:&quot;21582029.3743a&quot;,&quot;name&quot;:&quot;... to local server&quot;,&quot;justValue&quot;:true,&quot;showStatusActivities&quot;:true,&quot;showErrors&quot;:true,&quot;x&quot;:1954.01997756958,&quot;y&quot;:433.00394344329834,&quot;wires&quot;:[[&quot;17416cc1.3e6113&quot;]]},{&quot;id&quot;:&quot;17416cc1.3e6113&quot;,&quot;type&quot;:&quot;OPCUA-IIoT-Response&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;Wait for answer&quot;,&quot;compressStructure&quot;:false,&quot;showStatusActivities&quot;:false,&quot;showErrors&quot;:false,&quot;activateUnsetFilter&quot;:false,&quot;activateFilters&quot;:false,&quot;negateFilter&quot;:false,&quot;filters&quot;:[],&quot;x&quot;:2193.0200691223145,&quot;y&quot;:433.00399684906006,&quot;wires&quot;:[[&quot;33609b88.7c4cc4&quot;]]},{&quot;id&quot;:&quot;33609b88.7c4cc4&quot;,&quot;type&quot;:&quot;debug&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;&quot;,&quot;active&quot;:false,&quot;tosidebar&quot;:true,&quot;console&quot;:false,&quot;tostatus&quot;:false,&quot;complete&quot;:&quot;true&quot;,&quot;x&quot;:2380.0200958251953,&quot;y&quot;:433.00395011901855,&quot;wires&quot;:[]},{&quot;id&quot;:&quot;6198d7d9.ae24f8&quot;,&quot;type&quot;:&quot;switch&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;Test xSent = false&quot;,&quot;property&quot;:&quot;payload[2].value&quot;,&quot;propertyType&quot;:&quot;msg&quot;,&quot;rules&quot;:[{&quot;t&quot;:&quot;false&quot;}],&quot;checkall&quot;:&quot;true&quot;,&quot;repair&quot;:false,&quot;outputs&quot;:1,&quot;x&quot;:1117.019618988037,&quot;y&quot;:248.00393104553223,&quot;wires&quot;:[[&quot;33c9ab4f.6e6904&quot;]]},{&quot;id&quot;:&quot;e4f13e7.aeee0c&quot;,&quot;type&quot;:&quot;OPCUA-IIoT-Node&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;injectType&quot;:&quot;write&quot;,&quot;nodeId&quot;:&quot;ns=5;s=Arp.Plc.Eclr/MainInstance.xSent&quot;,&quot;datatype&quot;:&quot;Boolean&quot;,&quot;value&quot;:&quot;&quot;,&quot;name&quot;:&quot;Send xSent ...&quot;,&quot;topic&quot;:&quot;ns=5;s=Arp.Plc.Eclr/MainInstance.xSent&quot;,&quot;showErrors&quot;:false,&quot;x&quot;:1706.5197410583496,&quot;y&quot;:431.00401973724365,&quot;wires&quot;:[[&quot;e7f659ad.f856d8&quot;]]},{&quot;id&quot;:&quot;bbf31571.bd4798&quot;,&quot;type&quot;:&quot;change&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;set xSent = false&quot;,&quot;rules&quot;:[{&quot;t&quot;:&quot;set&quot;,&quot;p&quot;:&quot;payload&quot;,&quot;pt&quot;:&quot;msg&quot;,&quot;to&quot;:&quot;false&quot;,&quot;tot&quot;:&quot;bool&quot;}],&quot;action&quot;:&quot;&quot;,&quot;property&quot;:&quot;&quot;,&quot;from&quot;:&quot;&quot;,&quot;to&quot;:&quot;&quot;,&quot;reg&quot;:false,&quot;x&quot;:1342.519832611084,&quot;y&quot;:426.00395011901855,&quot;wires&quot;:[[&quot;e4f13e7.aeee0c&quot;]]},{&quot;id&quot;:&quot;7c7aec60.dd4ea4&quot;,&quot;type&quot;:&quot;switch&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;Test xSend = false&quot;,&quot;property&quot;:&quot;payload[0].value&quot;,&quot;propertyType&quot;:&quot;msg&quot;,&quot;rules&quot;:[{&quot;t&quot;:&quot;false&quot;}],&quot;checkall&quot;:&quot;true&quot;,&quot;repair&quot;:false,&quot;outputs&quot;:1,&quot;x&quot;:870.5195732116699,&quot;y&quot;:423.0039119720459,&quot;wires&quot;:[[&quot;bbf31571.bd4798&quot;]]},{&quot;id&quot;:&quot;abdef645.a4af28&quot;,&quot;type&quot;:&quot;debug&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;&quot;,&quot;active&quot;:false,&quot;tosidebar&quot;:true,&quot;console&quot;:false,&quot;tostatus&quot;:false,&quot;complete&quot;:&quot;false&quot;,&quot;x&quot;:1019.8945503234863,&quot;y&quot;:638.6757850646973,&quot;wires&quot;:[]},{&quot;id&quot;:&quot;4b371b6a.c3f7c4&quot;,&quot;type&quot;:&quot;debug&quot;,&quot;z&quot;:&quot;10110044.30b59&quot;,&quot;name&quot;:&quot;&quot;,&quot;active&quot;:true,&quot;tosidebar&quot;:true,&quot;console&quot;:false,&quot;tostatus&quot;:false,&quot;complete&quot;:&quot;true&quot;,&quot;x&quot;:1576.01953125,&quot;y&quot;:116.00390815734863,&quot;wires&quot;:[]},{&quot;id&quot;:&quot;21582029.3743a&quot;,&quot;type&quot;:&quot;OPCUA-IIoT-Connector&quot;,&quot;z&quot;:&quot;&quot;,&quot;discoveryUrl&quot;:&quot;&quot;,&quot;endpoint&quot;:&quot;opc.tcp://127.0.0.1:4840&quot;,&quot;keepSessionAlive&quot;:true,&quot;loginEnabled&quot;:false,&quot;securityPolicy&quot;:&quot;Basic128Rsa15&quot;,&quot;securityMode&quot;:&quot;SIGNANDENCRYPT&quot;,&quot;name&quot;:&quot;LOCAL SERVER&quot;,&quot;showErrors&quot;:true,&quot;individualCerts&quot;:false,&quot;publicCertificateFile&quot;:&quot;&quot;,&quot;privateKeyFile&quot;:&quot;&quot;,&quot;defaultSecureTokenLifetime&quot;:&quot;&quot;,&quot;endpointMustExist&quot;:false,&quot;autoSelectRightEndpoint&quot;:false,&quot;strategyMaxRetry&quot;:&quot;&quot;,&quot;strategyInitialDelay&quot;:&quot;&quot;,&quot;strategyMaxDelay&quot;:&quot;&quot;,&quot;strategyRandomisationFactor&quot;:&quot;&quot;,&quot;requestedSessionTimeout&quot;:&quot;&quot;,&quot;connectionStartDelay&quot;:&quot;&quot;,&quot;reconnectDelay&quot;:&quot;&quot;,&quot;maxBadSessionRequests&quot;:&quot;10&quot;}]`
