# Managed TagProvider breaks when connection is lost

**URL:** <https://forum.inductiveautomation.com/t/managed-tagprovider-breaks-when-connection-is-lost/77194>\
**Category:** Module Development\
**Created:** [August 1, 2023, 7:03am UTC](https://forum.inductiveautomation.com/t/managed-tagprovider-breaks-when-connection-is-lost/77194 "2023-08-01T07:03:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@scott](https://forum.inductiveautomation.com/u/scott)\
**Post date:** [August 1, 2023, 7:03am UTC](https://forum.inductiveautomation.com/t/managed-tagprovider-breaks-when-connection-is-lost/77194/1 "2023-08-01T07:03:53Z")

</div>

We are developing a module that uses a managed tag provider to expose MQTT data as tags.  
We have noticed when we lose network connection, the tag provider becomes unresponsive.

So far the only way we have found to fix this is by destroying and recreating the tag provider (currently by restarting the module, but looking do this automatically on reconnect.

Interestingly, we do not get any errors thrown in the java code (nothing to try/catch) but do get the below log item in the wrapper:

```auto
INFO | jvm 1 | 2023/08/01 16:07:36 | W [t.m.provider] [06:07:35]: Attempting to configure managed tag '[]System Status/Messages received' when provider '' has not been started. provider=

```

Has anyone else experienced something similar or know of a more graceful way to handle network disconnect/reconnect for managed tag providers?

cheers

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 1, 2023, 12:22pm UTC](https://forum.inductiveautomation.com/t/managed-tagprovider-breaks-when-connection-is-lost/77194/2 "2023-08-01T12:22:14Z")

</div>

Sounds like a bug in one or more object lifetimes. But that is just a guess.

---

<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:** [August 1, 2023, 12:28pm UTC](https://forum.inductiveautomation.com/t/managed-tagprovider-breaks-when-connection-is-lost/77194/3 "2023-08-01T12:28:53Z")

</div>

Can you share code, or significantly more details if not?

ManagedTagProviders exist and function entirely independent of any kind of network access. You're really asking us to look into a crystal ball and figure out what's wrong with your code at this point.

---

<div class="post-metadata">

**Author:** ![scott](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@scott](https://forum.inductiveautomation.com/u/scott)\
**Post date:** [August 3, 2023, 3:17am UTC](https://forum.inductiveautomation.com/t/managed-tagprovider-breaks-when-connection-is-lost/77194/4 "2023-08-03T03:17:45Z")

</div>

Relevant snippets:

```auto
configuration = new ProviderConfiguration("Provider");
        configuration.setAllowTagCustomization(true);
        configuration.setAllowTagDeletion(true);
        configuration.setPersistTags(true);
        configuration.setPersistValues(true);

        configuration.setAttribute(TagProviderMeta.FLAG_HAS_OPCBROWSE, true);
        configuration.setAttribute(TagProviderMeta.FLAG_PROVIDES_COMPLEX_TYPES, true);
        configuration.setAttribute(TagProviderMeta.FLAG_SUPPORTS_HISTORY, true);
        this.context = context;
        this.settings = settings;
        GatewayTagManager tagManager = context.getTagManager();
        this.provider = tagManager.getOrCreateManagedProvider(configuration);

```

and when we want to write to a tag, we do:

```auto
this.provider.configureTag(tagName, dataType);
this.provider.updateValue(tagName, value, QualityCode.Good);

```

I suppose a better high level question might be, is reinitializing the managedTagProvider after losing the underlying data source the right way to go?
