MIP SDK 26.1.2: First GetItemsByKind(Kind.Server) call causes delay in camera item retrieval

Hi,

I am using Milestone MIP SDK 26.1.2 in a .NET Framework application, and I am facing a delay when initially fetching the camera item during the first connection to a Milestone Server.

My current login/configuration flow is:

Environment.Initialize();
Environment.AddServer(…);
Environment.Login(…);
Environment.LoadConfiguration(serverUri);

Configuration.Instance.GetItemsByKind(Kind.Server); // Takes around 20 seconds on first call
VideoOS.Platform.Configuration.Instance.GetItem(cameraGuid, Kind.Camera);

Environment.Login() and Environment.LoadConfiguration() both complete successfully within a few seconds.

However, after the SDK login is succeeded, the first call to:

Configuration.Instance.GetItemsByKind(Kind.Server);

takes approximately 20 seconds to complete.

Additionally, this delay varies depending on the Milestone Server. For example, on other Milestone Server the same first call takes around 8 seconds, while on others it takes 20 seconds.

It is also noticed that:

Configuration.Instance.GetItem(cameraGuid, Kind.Camera);

can retrieve the camera only after Configuration.Instance.GetItemsByKind(Kind.Server) has completed. Before that first GetItemsByKind(Kind.Server) call finishes, GetItem(cameraGuid, Kind.Camera) does not return the camera item. Once GetItemsByKind(Kind.Server) completes after the 20-second delay, the camera item becomes available immediately.

After this initial call completes:

  • Camera configuration can be retrieved successfully.

  • Live streaming works correctly.

  • Subsequent calls to GetItemsByKind(Kind.Server) completed very quickly.

It is also observed that if the application first connects to another Milestone server, for example Milestone server B, and then connects to Milestone server A within the same application process, there is no delay when calling GetItemsByKind(Kind.Server) for Milestone server A.

So the delay appears to happen only on the first connection after the application starts.

Could you please clarify the following?

  1. Why does Configuration.Instance.GetItem(cameraGuid, Kind.Camera) appear to depend on Configuration.Instance.GetItemsByKind(Kind.Server) before the camera item can be retrieved?

  2. Is there a recommended way to warm up or preload the SDK after login so this initial delay can be avoided?

  3. Is there another SDK API that performs the required initialization more efficiently than calling Configuration.Instance.GetItemsByKind(Kind.Server)?

This delay causes the first live stream to load very slowly, taking more than 20 seconds, because the live stream can only be started after the camera item has been retrieved.

Any guidance or recommended best practice would be greatly appreciated.

Thank you.

Hi Muhammed,
Let me ask you a few questions. AddServer and LoadConfiguration, are they both on the same server? Also you don’t have more servers added?

Hi,

Yes, both Environment.AddServer() and Environment.LoadConfiguration(serverUri) are executed using the same Management Server URI. The same serverUri is passed throughout the login flow:

Environment.Initialize();

Environment.AddServer(serverUri, …);

Environment.Login(serverUri, …);

Environment.LoadConfiguration(serverUri);

At the time of the first connection, only one server has been added to the SDK. No additional servers have been added before calling Configuration.Instance.GetItemsByKind(Kind.Server).

The observed behavior is that during the first application startup, Configuration.Instance.GetItemsByKind(Kind.Server) takes approximately 20 seconds to complete. During this period, Configuration.Instance.GetItem(cameraGuid, Kind.Camera) is unable to retrieve the camera item.

Once GetItemsByKind(Kind.Server) completes, the camera item becomes available immediately, and all subsequent calls are very fast.

Another observation is that if the same Milestone server is connected after another Milestone server has already been connected within the same application process, there is no similar delay. The first call to Configuration.Instance.GetItemsByKind(Kind.Server) completes quickly, and Configuration.Instance.GetItem(cameraGuid, Kind.Camera) is able to retrieve the camera immediately.

The delay occurs only when connecting to Milestone server for the first time after the application starts.

Hi,

Could you please help resolve the above issue?

Hi Muhammed,

I am sorry for delayed reply. I have reported this issue to Milestone Development.
They will start an investigation and we will get back to you as soon as there’s updates from them.

Best Regards, Rie

Hi Muhammed,

We got an update from Milestone Development, please see below.

The Enviroment.LoadConfiguration(serverURI) is the correct call to re-load the configuration.

The URI must match the original uri, if it does not the call is ignore and a log message is written in the MIP log file.

Hi Rie,

Thank you for the update.

I have verified that the same serverURI is used throughout the login flow, and Environment.LoadConfiguration(serverURI) completes successfully.

Main concern is the initial execution of:

Configuration.Instance.GetItemsByKind(Kind.Server);

This call takes around 20 seconds to complete on the first connection (depending on the Milestone server).

During this time,

Configuration.Instance.GetItem(cameraGuid, Kind.Camera);

is not able to retrieve the camera item. The camera item becomes available only after Configuration.Instance.GetItemsByKind(Kind.Server) completes, and all subsequent SDK calls are very fast.

Could you please clarify if there is a better/recommended way to retrieve the camera item using:

Configuration.Instance.GetItem(cameraGuid, Kind.Camera);

without first having to call:

Configuration.Instance.GetItemsByKind(Kind.Server);

Currently, GetItem(cameraGuid, Kind.Camera) does not return the camera item until the initial GetItemsByKind(Kind.Server) call completes.

I have updated the internal report to Milestone Development. We will get back to you as soon as there’s updates from them.

Hi Muhammed,

We got an update from Milestone Development.

The LoadConfiguration loads the basic items from the VMS server, while the GetItemsByKind searches through additional possible item types, like Smart Wall, ViewLayouts and any partner plugin that might be loaded.

So, either change the call to GetItemsByKind(server) to a more specific call , or call the GetItemsByKind during the login process.