Adding a MIP Driver to a recording server programatically

We get a strange error when trying to add a new MIP Driver on a recording server with code.

We tested on 2023R2 but on this particular server it does not work and give the following error:

8:47:17 AM 10/26/2023 AddMIPDriver Will now attempt to add MIP Driver to with port = 52126 using driver path HardwareDriver[5ad3007e-6d63-47ee-9beb-8665a9bf2bdf]

8:47:24 AM 10/26/2023 AddMIPDriver Hardware add task: Error

8:47:24 AM 10/26/2023 AddMIPDriver 60281: VMO60281: Could not add the hardware.

It was not possible to connect to or receive information from the hardware. Verify that the following is correct: address, port, user name, password and hardware driver.

The code is running in an Event Server background plugin and is as follows:

string randomMAC = MacAddress.GetRandomMac();
                Logger.Log($"Random generated MAC: {randomMAC}");
                _parameters = new Dictionary<string, string>
                {
                    { "Mac", randomMAC}, //"04B7E1518B214BB" },
                    { "Firmware", "v10" },
                    { "Codec", "Jpeg" },
                    { "CodecList", "Jpeg" },        // Mpeg,H264  later
                    { "FpsRange", "1-30" },
                    { "QualityRange", "1-100" },
                    { "Gop", "NotSupported" },
                    { "Fps", "5" },                 // Update later in session ?
                    { "Resolution", "800x600" },    // Update later in session ?
                    { "Quality", "75" },            // Update later in session ?
                    { "ResolutionList", "800x600" },
                    { "SerialNr", "NotSupported" },
                    { "GopRange", "NotSupported" },
                    { "Model", "UIVideoProvider" }
                };
 
                // Open the HTTP Service
                _mediaProviderService = new MediaProviderService();
                _mediaProviderService.Init(_Config.SETTDriverPort, "password", _parameters);
 
                Logger.Log($"Camera initializing on port {_Config.SETTDriverPort}");
 
                StartAcceptSessions();
 
                AddMIPDriver(_Config.SETTDriverPort);

And the AddMIPDriver code is as follows:

ManagementServer managementServer = new ManagementServer(EnvironmentManager.Instance.MasterSite);
            RecordingServer recordingServer = managementServer.RecordingServerFolder.RecordingServers.FirstOrDefault(x => x.Id.ToLowerInvariant() == _Config.DefaultRecordingServerId);
            if (recordingServer == null)
            {
                Logger.Log($"Error. No recording servers found with ID={_Config.DefaultRecordingServerId}.");//Did not find recording server with ID: " + GlobalConfig.DefaultRecordingServerIdStatic);
                return false;
            }          
 
            string driverName = "MIP Driver";            
 
            string hardwareDriverPath = recordingServer.HardwareDriverFolder.HardwareDrivers.Where(x => x.Name == "MIP Driver").FirstOrDefault()?.Path;
            if (hardwareDriverPath == null)
            {
                Logger.Log("Error. Did not find hardware driver: " + driverName);
                Logger.Log("Here is the list of Drivers:");
                foreach (var hd in recordingServer.HardwareDriverFolder.HardwareDrivers.OrderBy(x => x.Name)) 
                {
                    Logger.Log($"\t{hd.Name}");
                }
 
                return false;
            }
            Logger.Log($"Will now attempt to add {driverName} to with port = {port} using driver path {hardwareDriverPath}");
            ServerTask addHardwareServerTask = null;
            int retries = 5;
            do
            {
                addHardwareServerTask = recordingServer.AddHardware($"127.0.0.1:{port}", hardwareDriverPath, "root", "password");
                while (addHardwareServerTask.State != StateEnum.Error && addHardwareServerTask.State != StateEnum.Success)
                {
                    System.Threading.Thread.Sleep(100);
                    addHardwareServerTask.UpdateState();
                }
                retries--;
                if (addHardwareServerTask.State == StateEnum.Error)
                {
                    Logger.Log("Hardware add task: " + addHardwareServerTask.State);
                    Logger.Log($"{addHardwareServerTask.ErrorCode}: {addHardwareServerTask.ErrorText}");
                }
            } while (addHardwareServerTask.State == StateEnum.Error && retries > 0);

Are there any logs that could help us solve the issue?

Thanks.

Do I understand correctly, that you have used this on other servers but in one instance it does not work?

If this is correct my first instinct would not be to look for flaws in the code. Instead I would try to find out why the one server is special.

I guess you have developed a software “device” that use the MIP Driver (like the CameraMetadataProvider sample). Are you able to install it and make it work in your test servers?

Are you able to install it in this VMS if you do it manually in the Management Client instead of using code?

Try to test in a way where you can determine whether it is your MIP Driver device, the code for adding it to the VMS or the one VMS site that is the cause for it not to work.

--

Samples that do similar to what I envision you are doing..

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

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

Thanks for your reply, we installed a Recording Server on the Management Server and it works fine, I think it is something with a firewall or their AI driven antivirus software. I am not sure if the client will try to debug this further, they are happy to use the MIP Driver on the new local Recording Server.