# Using system.opc.readValue() on a remote gateway

**URL:** <https://forum.inductiveautomation.com/t/using-system-opc-readvalue-on-a-remote-gateway/21748>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [January 8, 2019, 6:43pm UTC](https://forum.inductiveautomation.com/t/using-system-opc-readvalue-on-a-remote-gateway/21748 "2019-01-08T18:43:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibrandstetter](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@ibrandstetter](https://forum.inductiveautomation.com/u/ibrandstetter)\
**Post date:** [January 8, 2019, 6:43pm UTC](https://forum.inductiveautomation.com/t/using-system-opc-readvalue-on-a-remote-gateway/21748/1 "2019-01-08T18:43:22Z")

</div>

I have a runtime/tag architecture, where the vision windows are hosted on Server1, and the tags are hosted on Server2.

Server1 is connected to Server2 through the Gateway network.

I would like to have a script execute from a button press that fetches tag values using system.opc.readValue(Server, Path).

I know that this is possible using tag event scripts, but is there any way to do it directly from a component with this architecture?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 8, 2019, 8:30pm UTC](https://forum.inductiveautomation.com/t/using-system-opc-readvalue-on-a-remote-gateway/21748/2 "2019-01-08T20:30:46Z")

</div>

I don’t see why not…  
[system.opc.readValue](https://docs.inductiveautomation.com/display/DOC79/system.opc.readValue)

This link is useful for future needs, I use it all the time.  
[scripting functions](https://docs.inductiveautomation.com/display/DOC79/Scripting+Functions)

---

<div class="post-metadata">

**Author:** ![ibrandstetter](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@ibrandstetter](https://forum.inductiveautomation.com/u/ibrandstetter)\
**Post date:** [January 9, 2019, 3:32pm UTC](https://forum.inductiveautomation.com/t/using-system-opc-readvalue-on-a-remote-gateway/21748/3 "2019-01-09T15:32:29Z")

</div>

Thanks for the link. I suppose i should clarify that my script does work when both the vision client, and the tags are on the same gateway.

My issues started when i switched over to the architecture described in the original question.

From further research/testing, i believe that I would need to change my “Server” input to the scripting argument to point to the other server e.g.

returnValue = system.opc.readValue(“[internal.Server2.com](http://internal.Server2.com)”, “My tag path”)

I have not yet found any ignition documentation that details what to use for the “Server” input.

My current best guess would be to configure a new server under: “Gateway/Configure/OPC CONNECTIONS/Servers”. I am currently gathering the hardware required to test this method, but if anyone has some insight on this issue, I would appreciate it.

---

<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:** [January 9, 2019, 3:37pm UTC](https://forum.inductiveautomation.com/t/using-system-opc-readvalue-on-a-remote-gateway/21748/4 "2019-01-09T15:37:23Z")

</div>

You would need to add an OPC connection from Server 1 to Server 2 if you wanted to use `system.opc` calls against Server 2 from Server 1.

If the OPC values you’re trying to read already exist as Ignition tags in Server 2, though, you should just be using `system.tag` calls instead because you already have access to them as remote tags.

---

<div class="post-metadata">

**Author:** ![ibrandstetter](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@ibrandstetter](https://forum.inductiveautomation.com/u/ibrandstetter)\
**Post date:** [January 9, 2019, 7:05pm UTC](https://forum.inductiveautomation.com/t/using-system-opc-readvalue-on-a-remote-gateway/21748/5 "2019-01-09T19:05:18Z")

</div>

Kevin, a quick follow up question on this topic…

Do you know of a way to retrieve the path to a server from a tag provider?

Essentially, I would like to be able to do something like: server = system.getServer(“A Tag Provider”). Where server would then equal: “[internal.Server2.com](http://internal.Server2.com)”

Are you aware of anything that can do this?

---

<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:** [January 9, 2019, 7:08pm UTC](https://forum.inductiveautomation.com/t/using-system-opc-readvalue-on-a-remote-gateway/21748/6 "2019-01-09T19:08:08Z")

</div>

I don’t think anything like that exists.

You could manually maintain a dataset tag that maps that information in 2 columns. Maybe someone else has a better idea.
