# Opc connection state unknown

**URL:** <https://forum.inductiveautomation.com/t/opc-connection-state-unknown/57161>\
**Category:** Module Development\
**Tags:** ignition81\
**Created:** [March 14, 2022, 2:52pm UTC](https://forum.inductiveautomation.com/t/opc-connection-state-unknown/57161 "2022-03-14T14:52:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hello\_world007](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hello\_world007](https://forum.inductiveautomation.com/u/Hello_world007)\
**Post date:** [March 14, 2022, 2:52pm UTC](https://forum.inductiveautomation.com/t/opc-connection-state-unknown/57161/1 "2022-03-14T14:52:22Z")

</div>

Hi Team,

We are working on migrating one of our modules from Ignition 7.9 to 8.1. In our module we are creating a custom implementation of OPC Connection (in 7.9, we implemented for SROPCServer) and OpcConnectionType. So far we have made some changes to make it compatible with Ignition 8.1 and its compiling successfully. The module is getting installed successfully as well in the Ignition 8.1. But when we are trying to create a new OPC Connection then the connection state remains unchanged as ‘Unknown’, whereas logs in the custom implementation class shows the connection state to be ‘Connected’. Any idea why on Ignition Server the Opc connection state is not getting changed?

---

<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:** [March 14, 2022, 2:57pm UTC](https://forum.inductiveautomation.com/t/opc-connection-state-unknown/57161/2 "2022-03-14T14:57:07Z")

</div>

The state value comes from `OpcConnection::getState`.

It looks like the only time we’d substitute in `State.UNKNOWN` is when `OpcConnectionManager::getConnectionState` is given the name of an OPC server that doesn’t exist in the manager’s bookkeeping.

---

<div class="post-metadata">

**Author:** ![Hello\_world007](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hello\_world007](https://forum.inductiveautomation.com/u/Hello_world007)\
**Post date:** [March 14, 2022, 3:56pm UTC](https://forum.inductiveautomation.com/t/opc-connection-state-unknown/57161/3 "2022-03-14T15:56:46Z")

</div>

We have overridden OpcConnection::getState to provide the current state of the connection. This is providing the updated state as ‘Connected’ as well. I believe this should also refresh the connection state on the ignition server right? Or do we need to explicitly do something in Ignition 8.1 to achieve the same?

---

<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:** [March 14, 2022, 4:06pm UTC](https://forum.inductiveautomation.com/t/opc-connection-state-unknown/57161/4 "2022-03-14T16:06:18Z")

</div>

You shouldn’t need to do anything. Are you sure this method is being called at whatever page in the gateway you’re viewing it?

How did you create the connection instance - manually in code or by going through the gateway web UI?

---

<div class="post-metadata">

**Author:** ![Hello\_world007](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hello\_world007](https://forum.inductiveautomation.com/u/Hello_world007)\
**Post date:** [March 14, 2022, 4:22pm UTC](https://forum.inductiveautomation.com/t/opc-connection-state-unknown/57161/5 "2022-03-14T16:22:25Z")

</div>

We are using Gateway web UI. In the UI, we are using Opc Connections → Create new Opc Connection → Selected the custom module that we have implemented and added few configurations that are required for our module. The connection is getting created successfully but the status of the connection remains Unknown. We have added a debug log explicitly to check the state using OpcConnection::getState() where it gives the state as Connected.

---

<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:** [March 14, 2022, 4:23pm UTC](https://forum.inductiveautomation.com/t/opc-connection-state-unknown/57161/6 "2022-03-14T16:23:30Z")

</div>

What page are you viewing the Unknown status? If you breakpoint or put a logger in your `getState` method does it trigger every time you refresh that page?

---

<div class="post-metadata">

**Author:** ![Hello\_world007](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hello\_world007](https://forum.inductiveautomation.com/u/Hello_world007)\
**Post date:** [March 14, 2022, 5:09pm UTC](https://forum.inductiveautomation.com/t/opc-connection-state-unknown/57161/7 "2022-03-14T17:09:31Z")

</div>

We are using the Opc Connections page to view all the connections and their respective states.

“_If you breakpoint or put a logger in your `getState` method does it trigger every time you refresh that page?_” → Thanks for the lead. I do see repeated calls to getState. I need to further look into our code base to see where the state is getting set to unknown back from connected.
