# OPC Connection Tag Sate

**URL:** <https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812>\
**Category:** Ignition\
**Created:** [November 22, 2022, 4:40pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812 "2022-11-22T16:40:48Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [November 22, 2022, 4:40pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/1 "2022-11-22T16:40:48Z")

</div>

Hi,

I want to know the OPC Connection State (Connected or Disconnected).  
I am searching for a tag but didnt found such tag.  
I want to generate an alarm when OPC connections is lost.  
How Can I do this?  
Any idea?

Thanks.

---

<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:** [November 22, 2022, 4:42pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/2 "2022-11-22T16:42:03Z")

</div>

Every OPC connection has a Gateway System Tag that indicates its connection status.

[https://docs.inductiveautomation.com/display/DOC81/System+Tags#SystemTags-GatewaySystemTags](https://docs.inductiveautomation.com/display/DOC81/System+Tags#SystemTags-GatewaySystemTags)

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [November 22, 2022, 4:45pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/3 "2022-11-22T16:45:24Z")

</div>

I can see only these system tags.  
I think I am using lower version 7.3, it is not available for this version.  
any idea for 7.3 version, how we will get OPC Connection Stae?

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/b/1ba28480d7841526b2a464665d7dc208beae1f01.png)

---

<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:** [November 22, 2022, 4:48pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/4 "2022-11-22T16:48:32Z")

</div>

Sorry, I don't think there's anything that can help you out in 7.3. Too old.

---

<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:** [November 22, 2022, 4:49pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/5 "2022-11-22T16:49:46Z")

</div>

Actually, it might be worth seeing if `system.opc.getServerState` exists in 7.3: [system.opc.getServerState - Ignition User Manual 7.9 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC79/system.opc.getServerState)

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [November 22, 2022, 4:49pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/6 "2022-11-22T16:49:58Z")

</div>

How about this function?  
will it work for me?

Actually I am trying but not working.

if((runScript(“system.opc.getServerState(‘Matrikon UCS’)”,5000)) = “CONNECTED”,  
“1”,  
“0”)

---

<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:** [November 22, 2022, 4:51pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/7 "2022-11-22T16:51:52Z")

</div>

Does it work when called in a gateway timer script?

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [November 22, 2022, 4:58pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/8 "2022-11-22T16:58:37Z")

</div>

Not tried on timer script.  
I tried on expression tag.  
How I will get Name of OPC Server connection?  
I am not sure I am passing correct value or Not.

---

<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:** [November 22, 2022, 5:03pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/9 "2022-11-22T17:03:09Z")

</div>

Go to the configuration section of the gateway and look at what it's configured as.

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [November 22, 2022, 5:04pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/10 "2022-11-22T17:04:59Z")

</div>

It is showing like this, What is name of the Connection from 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:** [November 22, 2022, 5:08pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/11 "2022-11-22T17:08:08Z")

</div>

Looks like you have a single connection called "Kepware".

Does the "Configure" area show the same name?

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [November 22, 2022, 5:09pm UTC](https://forum.inductiveautomation.com/t/opc-connection-tag-sate/66812/12 "2022-11-22T17:09:53Z")

</div>

Yes In Configure it is showing "Kepware".  
and I am trying to create one Expression tag like this but it's not working

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