Managed TagProvider breaks when connection is lost

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:

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

2 Likes

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

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.

Relevant snippets:

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:

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?