# OPC read/write not working

**URL:** <https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [February 20, 2024, 10:56pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065 "2024-02-20T22:56:25Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![imt.sebastian.sanche](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@imt.sebastian.sanche](https://forum.inductiveautomation.com/u/imt.sebastian.sanche)\
**Post date:** [February 20, 2024, 10:56pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/1 "2024-02-20T22:56:25Z")

</div>

Hi I have a similar issue with Designer V 8.1.30.

I have a full script to do write values but was not working so I tried to read values and it isn't either.

I did the most basic script to read values to a test tag that I also added to the tag browser so I could monitor it and still get the

> [null, Bad("Bad\_NodeIdUnknown: The node id refers to a node that does not exist in the server address space.")

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/0670d8022887a7845bf56777a4de85cbe9ad2b26.png)  
I have tried different tags in different scopes but nothing is working.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [February 20, 2024, 11:04pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/2 "2024-02-20T23:04:17Z")

</div>

Your tag name may be incorrect.

According to the manual, it would just be: `[BP2_CZ1]TestOPCWrite`

> **[system.opc.readValues | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-opc/system-opc-readValues#keywords)**
>
> This function is equivalent to the system.opc.readValue function, except that it can operate in bulk.

Edit: I just confirmed by looking at some scripting I'd done using system.opc.readValues and you don't prefix it with 'ns=1;s=' and I passed multiples in, but passed them as an array/list of tags. So it may not hurt to just put brackets around your path variable.

---

<div class="post-metadata">

**Author:** ![imt.sebastian.sanche](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@imt.sebastian.sanche](https://forum.inductiveautomation.com/u/imt.sebastian.sanche)\
**Post date:** [February 20, 2024, 11:06pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/3 "2024-02-20T23:06:03Z")

</div>

I tried with both `ns1;s=` and without it still the same result.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [February 20, 2024, 11:09pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/4 "2024-02-20T23:09:04Z")

</div>

Are you getting any other errors in the logger? It definitely shouldn't have 'ns=1;s=' prefixed, and ideally should be passed as a list, but not sure that's required.

---

<div class="post-metadata">

**Author:** ![imt.sebastian.sanche](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@imt.sebastian.sanche](https://forum.inductiveautomation.com/u/imt.sebastian.sanche)\
**Post date:** [February 20, 2024, 11:16pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/5 "2024-02-20T23:16:05Z")

</div>

I looked at the gateway logs on both the front end and back end (Tag gateway) and neither had errors related to the script. If I add the brackets to make them a list then I get an error for `arg can't be coerced to String`

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/0/309ad82772847a11fe9bc5fe03159877af06790f.png)

edit: to clarify I have 2 gateways, the front end (HMI) and back end (tag and journals)

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [February 20, 2024, 11:16pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/6 "2024-02-20T23:16:54Z")

</div>

The server should be a string, only the path should be made into a list.

---

<div class="post-metadata">

**Author:** ![imt.sebastian.sanche](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@imt.sebastian.sanche](https://forum.inductiveautomation.com/u/imt.sebastian.sanche)\
**Post date:** [February 20, 2024, 11:18pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/7 "2024-02-20T23:18:08Z")

</div>

Same error but now it describes for the 2nd arg

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [February 20, 2024, 11:18pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/8 "2024-02-20T23:18:11Z")

</div>

You should be running this script from the backend server would be my guess unless you're remotely connecting to the OPC server on the backend with the frontend gateway.

---

<div class="post-metadata">

**Author:** ![imt.sebastian.sanche](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@imt.sebastian.sanche](https://forum.inductiveautomation.com/u/imt.sebastian.sanche)\
**Post date:** [February 20, 2024, 11:19pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/9 "2024-02-20T23:19:23Z")

</div>

We have the remote providers set up correctly. I can browse the tags on the tag browser from the Designer but just the script doesn't want to work.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [February 20, 2024, 11:20pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/10 "2024-02-20T23:20:14Z")

</div>

I'm sorry, you're right. There are 2 functions, one for reading multiple values and one for reading a single value (readValue vs readValues).

Remote providers are different than talking OPC directly. To use providers you'd have to use the `system.tag.readBlocking()` function instead of `system.opc.readValue()`

Edit: Keep in mind this will require the tag path inside the provider, not the tag path in the PLC using OPC. So if a tag is in a folder, you'll have to include the full path to the tag on the remote tag provider.

---

<div class="post-metadata">

**Author:** ![imt.sebastian.sanche](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@imt.sebastian.sanche](https://forum.inductiveautomation.com/u/imt.sebastian.sanche)\
**Post date:** [February 20, 2024, 11:29pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/11 "2024-02-20T23:29:30Z")

</div>

Yeah I just tried it on the tag gateway, just created a dummy project to test the scrip and it works there. I'll play with the `system.Tag.readBlocking`

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 21, 2024, 1:21am UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/12 "2024-02-21T01:21:46Z")

</div>

Seems like you figured it out, but just to clarify: the `system.opc` functions only work against OPC servers defined on the local gateway.

It sounds like the tags in your screenshot are from a remote provider, so you don't actually have a PLC hooked up to the local OPC server that the function is operating against.

---

<div class="post-metadata">

**Author:** ![imt.sebastian.sanche](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@imt.sebastian.sanche](https://forum.inductiveautomation.com/u/imt.sebastian.sanche)\
**Post date:** [February 21, 2024, 6:28pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/13 "2024-02-21T18:28:19Z")

</div>

Hi Kevin, so wild thought can I connect the OPC from the gateway I have the PLCs at to my HMI gateway? I'm trying to understand the best way to go forward since I have several projects that have a similar architecture.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 21, 2024, 6:30pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/14 "2024-02-21T18:30:42Z")

</div>

Yes, you can make an OPC connection from one gateway to another (with some configuration changes to the OPC server on the other to allow it).

But since you already have gateway network and remote tag providers set up there's not really a good reason to go down that path.

---

<div class="post-metadata">

**Author:** ![imt.sebastian.sanche](https://avatars.discourse-cdn.com/v4/letter/i/ecb155/32.png) [@imt.sebastian.sanche](https://forum.inductiveautomation.com/u/imt.sebastian.sanche)\
**Post date:** [February 21, 2024, 6:34pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/15 "2024-02-21T18:34:31Z")

</div>

So if I understand correctly your recommendation would be to add the tags to the remote provider and do a `system.tag.writeblocking` instead connecting the OPC and do a `system.opc.write`?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 21, 2024, 6:35pm UTC](https://forum.inductiveautomation.com/t/opc-read-write-not-working/86065/16 "2024-02-21T18:35:52Z")

</div>

Yeah, might end up being easier since you already have it set up.

It's a little awkward to have to create a tag on the remote gateway just because you need it on the local. It would be nicer if the tag was used on both.
