Export Video - "Recording Server offline" error

I am attempting to export recorded videos from Milestone cameras using the MIPS SDK, however the export.Start() method shows an error: “Recording Server offline”

The export function works within the Milestone Export trial project so it is a problem within my application

I checked the forums and couldn’t find any solutions that worked.

Below is my export code:

CamNameList is an object that contains the names of all Milestone cameras on the network

                    AVIExporter aviExporter = new VideoOS.Platform.Data.AVIExporter()
                    {
                        Filename = "vid",
                        Codec = "Intel IYUV codec",
                        AudioSampleRate = 8000
                    };
                    VideoOS.Platform.Data.IExporter exporter = aviExporter;
                    exporter.Init();
                    exporter.Path = this.mDestination;
 
                    for (int i = 0; i < CamNameList.Count; i++)
                    {
                        if (CameraName == CamNameList[i])
                        {
                            List<Item> cams = FindAllCameras();
                            var audioSources = cams[i].GetRelated();
                            foreach (Item item in audioSources.ToList())
                            {
                                if (item.FQID.Kind != Kind.Microphone)
                                {
                                    audioSources.Remove(item);
                                }
                            }
                            exporter.CameraList = new List<Item> { cams[i] };
                            exporter.AudioList = audioSources;
                            break;
                        }
                    }
 
                   var isStarted = exporter.StartExport(this.ExportStartTime.ToUniversalTime(), this.ExportEndTime.ToUniversalTime());
 
                    if (isStarted)
                    {
                        int lastError = exporter.LastError;
                        string lastErrorString = exporter.LastErrorString;
                        //labelError.Text = lastErrorString + "  ( " + lastError + " )";
                        exporter.EndExport();
                    }
                }

Can you please explore Export sample? This sample might be helpful for you -

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

Hi Rie, I’ve tested the Export sample already & it’s ​working fine.

The problem is that using ​the same method within my application results in a “Recording Server Offline” error

Any updates on this?

I find it surprising that the sample works if your code fails, it seems so similar. Did you test with same camera, same period and same type of export? Will you be able to use the sample source code instead?

There is a known issue that this error might be generated if you export a camera where the database is empty (nothing is recorded). Might this be the issue? Please evaluate and let me know.

Yes I tested both my code and the export sample with the same camera, period and export type.

I also have playback working for the camera so the recordings are definitely being stored, also wouldn’t the export sample give me the same error if the Database was empty?

Are there any other situations in which this error is generated? Perhaps I’m forgetting to set a field in the exporter object?

Can you please tell me which version of the MIP SDK you are using?

I believe it’s 2019 R1

Please upgrade the MIP SDK and retest.

Tried again after installing 2019 R3, the issue has not been resolved

Please revert to the Export sample code. When adding more code / features please note what makes your solution start to fail.

Has there been a fix to that issue?

I have the exact same problemin XProtect 2022 R1. I have the feeling it has something to do with the connection to the server. While the sample uses the LoginDialog, in my own Application which is not based on WinForms, I simply use VideoOS.Platform.SDK.Environment.AddServer() and VideoOS.Platform.SDK.Environment.Login() with masterOnly set to false per default. It should therefore also connect to any recording servers when logging in automatically. My feeling of this being an issue, comes from the fact that in the LoginDialog still uses some other ServerConfigurationEnum.AllServersIndividually Property found in the documentation which I can find nowhere else. At the same time I can not find a sample to verify export functionality working with a connection where no LoginDialog is used (standalone application without WinForms). Besides the way of logging in, my code is exactly the same and yet I always get an error, stating that the recording server is not connected.

I am now even more convinced that it has to do with the connection established. When I use my own mentioned library that won’t export standalone and reference and run it in an application where I connect to the server with a LoginDialog, the export works perfectly fine. @Bo Ellegård Andersen (Milestone Systems)​ do you happen to know anything about the differences between login in with a LoginDialog vs the VideoOS.Platform.SDK.Environment?

Milestone Development tested the code (VideoOS.Platform.SDK.Environment.AddServer() and VideoOS.Platform.SDK.Environment.Login()) and it works in our tests.

In order to reproduce this issue, can you please provide us following information?

XProtect VMS product and version?

Do you have any special settings in your server? All in one server or distributed on multiple physical servers?

Have you tried unmodified Export sample and tell us whether it works or not?

Can you provide a code snippets to see the issue? (because Milestone Development have not seen the issue using VideoOS.Platform.SDK.Environment.AddServer() and VideoOS.Platform.SDK.Environment.Login().)

Does the CameraStreamResolution sample with its hardcoded login work for you?

Please share the snippet of code for login if different that what is used in that sample. - https://doc.developer.milestonesys.com/html/index.html?base=samples/componentsamples/camerastreamresolution/readme.html&tree=tree_2.html

Please note that VideoOS.Platform.SDK.UI.LoginDialog.DialogLoginForm.ServerConfigurationEnum is relevant for Milestone Federated Architecture (MFA) where you have child sites (a site has a Management Server and one or multiple Recording Servers).

We would love to reproduce or in other ways grasp what goes on, hopefully we can figure it out when you reply.

Thanks for the answer, I try to reply in a structured manner:

The Login using VideoOS.Platform.SDK.Environment.AddServer() and VideoOS.Platform.SDK.Environment.Login() is not the issue, it also works perfectly fine in my case, it’s just that using export functionality or a JPEGVideoSource after logging in that way, throws and makes issues. But more about that later.

The code I use in my standalone library to connect to my server (it is an all-in-one server with XProtect Corporate 2022 R1 installed) is the following and works perfectly fine:

CredentialCache basicCredentials;
basicCredentials = Util.BuildCredentialCache(_uri, _credentials.UserName, _credentials.Password, "Basic");
 
bool secureOnly = false;
bool masterOnly = false;
VideoOS.Platform.SDK.Environment.AddServer(secureOnly, _uri, basicCredentials, masterOnly);
VideoOS.Platform.SDK.Environment.Login(_uri, _integrationId, _integrationName, _version, _manufacturerName, masterOnly);

But then, in the same library, if I try to use any Exporter, the server throws an exception telling me:

VideoOS.Platform.CommunicationMIPException: Recorder offline -

Furthermore, when I try to grasp single JPEG frames using a JPEGVideoSource, the server throws as well - but this time a completely different Exception:

VideoOS.Toolkit.FileException : Could not open file 'CoreToolkits.dll'!

And this even though I am using NuGet packages. I also double checked all the build folders etc, and the CoreToolkits.dll library is in fact present everyhwere…

Now about the samples: both the unmodified Export Sample as well as the CameraStreamResolution sample work perfectly fine for me.

Therefore, I then wanted to test my library in the same environment and injected my library code into the ExportSample and tested it there:

[...]
 
DialogLoginForm loginForm = new DialogLoginForm(SetLoginResult, IntegrationId, IntegrationName, Version, ManufacturerName);
//loginForm.LoginLogoImage = MyOwnImage;				// Set own header image
Application.Run(loginForm);                             // Show and complete the form and login to server
if (Connected)
{
    // Run my own code.
    [...]
    var exporter = new CustomExporterWrapper(logger, tmpDirFullPath, exportCameras);
    exporter.Export(startTime, endTime, exportName);
 
    //Application.Run(new MainForm());
}

And to my surprise, my library then worked perfectly well, exporting both JPEG images and MKV videos without throwing any exceptions.

So, it seems that it’s either

  • an issue with my environment (and therefore the NuGet packages I use, since I do nothing else but import the VideoOS NuGet packages).
  • or with the log in (standalone component vs. the LoginDialog).

If required, I could give you access to my library and you could test it on your machine, just let me know, how I could reach you via E-Mail or similar.

Thanks, and best regards!

Hi Tobias, I was the one who tested exporting after logging in with VideoOS.Platform.SDK.Environment.AddServer() and VideoOS.Platform.SDK.Environment.Login() on a 22R1 Corporate server. I simply replaced the login dialog calls in the ExportSample component sample with those two calls, and was able to export video without any issues.

Could you show us the snippet of code that does the actual export, in your library? How does it differ from the ExportSample?

Best regards,

Simon

Hi Simon

Thanks for the investigation.

I created a simple snippet for you to replicate the issue and found out, that it might actually be an issue of running the code in a unit test using instead of just a standalone application.

In my own library I also only experienced the issues, when running the exporters in a unit-test.

So here is the simple ConsoleApplication that works fine standalone for me:

using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using VideoOS.Platform;
using VideoOS.Platform.Data;
using VideoOS.Platform.Login;
 
namespace MipExportConsoleApp
{
    public class Exporter
    {
        public static void Main()
        {
            var integrationId = Guid.NewGuid();
            var integrationName = "Some test component export integration.";
            var version = "0.0";
            var manufacturerName = "someManufacturer";
 
            VideoOS.Platform.SDK.Environment.Initialize();
            VideoOS.Platform.SDK.UI.Environment.Initialize();
            VideoOS.Platform.SDK.Export.Environment.Initialize();
 
            var uri = new Uri("http://localhost");
 
            CredentialCache basicCredentials;
            basicCredentials = Util.BuildCredentialCache(uri, "SomeUser", "SomePassword", "Basic");
 
            bool secureOnly = false;
            bool masterOnly = false;
            VideoOS.Platform.SDK.Environment.AddServer(secureOnly, uri, basicCredentials, masterOnly);
            VideoOS.Platform.SDK.Environment.Login(uri, integrationId, integrationName, version, manufacturerName, masterOnly);
 
            Console.WriteLine("Succesfully logged into server.");
 
            // Load a camera.
            Item camera = GetCameraFromString("Camera 1");
 
            Console.WriteLine("Succesfully fetched Camera 1.");
 
            exportMkv(camera);
        }
 
        static void exportMkv(Item camera)
        {
            string exportFileName = $"TestExport.mkv";
            string path = System.IO.Directory.GetCurrentDirectory();
            var mkvExporter = new MKVExporter()
            {
                Path = path,
                Filename = exportFileName,
                CameraList = new List<Item>() { camera }
            };
            mkvExporter.Init();
 
 
            DateTime startTime = DateTime.Now.AddHours(-1);
            DateTime endTime = startTime.AddMinutes(1);
 
            bool exportStarted;
            exportStarted = mkvExporter.StartExport(startTime, endTime);
 
            if (!exportStarted)
            {
                Console.WriteLine($"Could not start the MKV export for Camera 1 from {startTime} to {endTime} to the destination {path}: <{mkvExporter.LastErrorString}>");
            }
            else
            {
                Console.WriteLine($"Exporting MKV for Camera 1 from {startTime} to {endTime} to the destination {path}.");
                while (mkvExporter.Progress < 100)
                {
                    Thread.Sleep(10);
                }
                mkvExporter.Close();
                Console.WriteLine($"Finished the MKV export for <Camera 1>");
            }
        }
 
        static Item GetCameraFromString(string CameraItemName, List<Item> items = null)
        {
            items = items ?? Configuration.Instance.GetItemsByKindSorted(Kind.Camera);
            foreach (Item item in items)
            {
                if (item.Name.ToLower().Contains(CameraItemName.ToLower()))
                {
                    return item;
                }
                else
                {
                    if (item.GetChildren().Count != 0)
                    {
                        var result = GetCameraFromString(CameraItemName, item.GetChildren());
                        if (result != null)
                        {
                            return result;
                        }
                    }
                }
            }
            return null;
        }
 
    }
}

However, when I try to run it in a unit test from a separate project:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
 
namespace Exporter.Test
{
    public class TestExporter
    {
        [Fact]
        public void TestMain()
        {
            MipExportConsoleApp.Exporter.Main();
        }
    }
}

It initially throws the following error:

System.IO.FileNotFoundException : Could not load file or assembly 'System.IdentityModel.Tokens.Jwt, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

As soon as I add the VideoOS.Platform.SDK to the unit-test project, the error changes to:

    VideoOS.Platform.CommunicationMIPException : Recorder offline - 

Can you replicate this issue and maybe find out what goes wrong when running the exporters from a unit-test?

Could it have something to do, that the unit tests run in a separated thread?

The only Nuget packages I installed for this example are: VideoOS.Platform.SDK, xunit and xunit.runner.visualstudio.

It has been a few months and this is still not working for us in our library when running using xunit tests.

So I wanted to make a follow-up and ask whether you were able to reproduce the issue with my minimal sample above?

Hi

I’m getting the same error: “Recording Server offline” if the export time is in a time when the recording service was not running. If the service is running and nothing is recorded by the cameras we get the no data in the timeframe message which is what we want. Is there something that exporter fails on if the recording service is offline at a point in the export data time frame (not at the time of the export task of coarse)? We are using the SDK version 23.1.1

Cheers

We tried to reproduce the issue but no success so far. Can you please make a new question for this? Because this question thread is very old, and I don’t think it is the best idea to continue here in this thread. As we might be missing something, so it would be great if you could explain how to see/reproduce the issue.