ConfigurationChangedIndication in standalone service

Hello,

I want to use the ConfigurationChangedIndication to know when cameras have been added or deleted, so I can trigger a “VideoOS.Platform.SDK.Environment.ReloadConfiguration(EnvironmentManager.Instance.MasterSite);” to see the new cameras. The reloadConfiguration works fine, but the ConfigurationChangedIndication never fires.

Here is the code I am running, after having performed a successfull login. Anything worng with it?

if (LoginUsingCredentials(loginFailedLogged))
{
    Logger.Log("Login Success!!!");
    EnvironmentManager.Instance.EnableConfigurationChangedService = true;
                    EnvironmentManager.Instance.EnvironmentOptionsChangedEvent += 
    Instance_EnvironmentOptionsChangedEvent;                    
                    
    MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
                    _messageCommunication = 
    MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);
                    _MC_ServerChanged = _messageCommunication.RegisterCommunicationFilter(ConfigurationChanged, new 
    CommunicationIdFilter(MessageId.Server.ConfigurationChangedIndication));
}

ConfigUpdated sample does the same thing, please see if the sample works for you unmodified. If it works for you, please try to make comparisons on the code.

https://doc.developer.milestonesys.com/html/index.html?base=samples/configupdate.html&tree=tree_2.html

Hi Rie,

Thank you for the sample, but it’s not working either :confused:

When I start it, it gets the config, and it will log a name change or a new camera during the first 60-ish seconds… but after it receives the first message it stops updating for no apparent reason. nothing showing in Debug. Running latest SDK against a 2019R3 Corp Test Lic.

I have not reproduced the issue so far with XPCO 2019 R3 and SDK 2020 R2.

As the documentation mentioned that the sample has a delay of 15 seconds, and so had I while I was testing the sample, it was 1-2 minutes delay.

Might it be the same for you? Can you please test the sample and wait a few minutes more?

Hi Rie. Yes, that is exactly what’s happening. Can we speed it up? Just need to know if something got modified so I can reload everything but if we can get the added/removed working in 1-2s that would be awesome!

Hi Eric. As many applications (including the VMS build-in ones) react to a ConfigurationChangedIndication by reloading the entire configuration (since the notification does not include information about what has changed, that is pretty much the only thing to do), there has been implemented an automatic pause between subsequent change notifications of 1 minute.

That means that if a configuration change happens a notification will be send out right away, but if any other changes happen after that for the next minute the next notification will not be sent out until 1 minute after the first one.

This is to avoid overload of the system and is not configurable.

Hi Peter,

I managed to get the ConfigurationChangedIndication working instantly now. The ConfigurationMonitor enters the “SystemConfigurationChangedIndicationHandler” method right away, but it takes a minute for it to call the change timer function. I reload the configuration as soon as I get the event and I can see that new cameras are added immediately, even if I add new cameras every 10s. I did notice a problem however, deleted cameras remain in the list, even if I wait over a minutes to get the timer to trigger. Cameras stay in the list until I log off and logon. How can I get the removed cameras to get removed from the list? I am using this to get the camera names:

foreach (var cam in Configuration.Instance.GetItemsByKind(Kind.Camera, ItemHierarchy.SystemDefined)) 
            {
                Logger.Log($"Cam: {cam.Name}");
                foreach (var child in cam.GetChildren()) {
                    Logger.Log($"   sub: {child.Name}");
                    foreach (var subchild in child.GetChildren())
                    {
                        Logger.Log($"   subsub: {subchild.Name}");
                        foreach (var subsubchild in subchild.GetChildren())
                        {
                            Logger.Log($"   subsubsub: {subsubchild.Name}");
                        }
                    }
                }
            }

Hi Eric,

This is actually by design. In order not to make a camera just disappear it will instead be set to disabled. I know this is not the ideal solution in all scenarios, but…

So you will either have to relogin or if you don’t need to distinguish between disabled and removed cameras you can just look at the disabled flag.

/Peter