Need help understanding weild alarm timestamps

We are developing a Windows service that listens for Milestone alarms, and exports videos that start a few seconds before and ends a few seconds after the alarm timestamp.

It listens for alarms like this:

_msgObj1 = _messageCommunication.RegisterCommunicationFilter(NewAlarmMsgReciever, new CommunicationIdFilter(MessageId.Server.NewAlarmIndication), null, EndPointType.Server);

When an alarm is triggered, the thread sleeps for a few seconds so that the full video has time to be recorded, and then the export starts, using MKVExporter.

As soon as an alarm comes in, a log entry is created with the timestamp from the alarm’s EventHeader.Timestamp, and also with the time of the log entry itself. In most cases the two timestamps differ by less than a second as expected, but sometimes they differ by several seconds, minutes or over an hour. Often when this happens, the alarm is from after the log entry, ie. from the future, so obviously something is wrong.

When the time differs like this, one of two things can happen:

1. mkvExporter.StartExport fails with the following error: “NoVideoInTimeSpanMIPException: No video or audio in selected time period”

or

2. mkvExporter.StartExport succeeds but the export progress is stuck at 0% with mkvExporter.LastErrorString = “Unable to connect to toolkit!”

It gets stuck sometimes where all exports fail and the timestamp discrepancy gets larger and larger for every new alarm.

Any idea why this happens? I have not experienced this problem on my system, but it happens when our partner test it on their system. I’ll attach some Milestone logs that they sent, is there anything there that can explain this?

If you get wrong time stamps, like times in the future, there is no sense in even trying to use them to fetch images or export images.

I have an idea that a possible explanation could be a faulty clock.. Please see - https://developer.milestonesys.com/s/article/How-to-avoid-issues-related-to-time-time-zones-and-time-stamps

If that is not it..

Do you also create the events or alarms in your integration?

The server and cameras are supposedly in sync. The alarms are triggered from an alarm definition in Management Client with motion detected as trigger (system event).

Another problem is that sometimes the service stops getting notified about new alarms until it is restarted. The alarms can be seen in Smart Client but are not detected by our service. I would have guessed this is because the connection to Milestone is lost, but I started a bockground thread that periodically calls VideoOS.Platform.SDK.Environment.IsServerConnected which keeps returning true.

Could you as a reference please try to Alarm and Event Viewer sample unmodified? If the sample works you can compare your code with that of the sample.

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

https://github.com/milestonesys/mipsdk-samples-component

Apparently the sample works fine consistently. But I can’t see any significant difference between our code and the sample code. The difference is basically that our code runs as a service and exports videos.

Can you please check if there are any errors in MIP logs related to listening message communication?

Event server MIP logs are located - [C:\ProgramData\Milestone\XProtect](file:C:/ProgramData/Milestone/XProtect) Event Server\logs\MIPLogs

MIP logs are here - [C:\ProgramData\Milestone\MIPSDK](file:C:/ProgramData/Milestone/MIPSDK)

Also, if you have your application logs, please check it too.