How does the EventServer SOAP API work ?

I have a SOAP connection to the EventServer with the URL http://:22331/Central/AlarmServiceToken.

I have not found any documentation on the correct use of the session commands.

They do not work like the commands from “RecorderStatusService / RecorderStatusService2.asmx”

I started a session with “StartEventLineSession” and received a session ID.

Then I queried the events with “GetSessionEventLines”.

I receive events that are up to one day old. Why ?

I now poll the events with “GetSessionEventLines”, but I don’t get any new events, even though they occur. Why ?

Only when I start a new session will I receive the new events in the first “GetSessionEventLines” result including the previous events.

What am I doing wrong?

You may be using the client correctly and it’s just not behaving as expected. I tried to reproduce it unsuccessfully initially, until I noticed you’re calling “GetSessionEventLines” and not “GetSessionAlarmLines”.

My code to get alarm lines was working as expected, with new alarms available as fast as my polling could run. But when I copied that code and made the same calls to GetSessionEventLines, I could get all the events in the initial call, but subsequent calls did not seem to collect any new events. Here’s my test code for the record. I’ll pass this on to R&D to see if this is something that needs to be fixed.

private static async Task GetAlarmLines(MilestoneConnection conn, CancellationToken token)
{
    var filter = new AlarmFilter
    {
        Orders = new[]
        {
            new OrderBy
            {
                Order = Order.Ascending, 
                Target = Target.Timestamp
            }
        }
    };
 
    var ep = new EndpointAddress("http://ms3:22331/Central/AlarmServiceToken");
    var evt = new AlarmClient.AlarmCommandTokenClient(new BasicHttpBinding(), ep);
    var sessionId = evt.StartAlarmLineSession(conn.GetCurrentToken(),filter);
    while (!token.IsCancellationRequested)
    {
        var update = evt.GetSessionAlarmLines(conn.GetCurrentToken(), 100, sessionId);
        foreach (var line in update.Inserted)
        {
            Console.WriteLine($"NEW ALARM: {line.Timestamp} - {line.Message}");
        }
        await Task.Delay(100, token);
    }
}
 
private static async Task GetEventLines(MilestoneConnection conn, CancellationToken token)
{
    var filter = new EventFilter()
    {
        Orders = new[]
        {
            new OrderBy
            {
                Order = Order.Ascending,
                Target = Target.Timestamp
            }
        }
    };
 
    var ep = new EndpointAddress("http://ms3:22331/Central/AlarmServiceToken");
    var evt = new AlarmClient.AlarmCommandTokenClient(new BasicHttpBinding(), ep);
    var sessionId = evt.StartEventLineSession(conn.GetCurrentToken(), filter);
    while (!token.IsCancellationRequested)
    {
        var update = evt.GetSessionEventLines(conn.GetCurrentToken(), 100, sessionId);
        foreach (var line in update.Inserted)
        {
            Console.WriteLine($"NEW EVENT: {line.Timestamp} - {line.Message}");
        }
        await Task.Delay(100, token);
    }
}

Hi Thomas,

I just wanted to let you know that while I was building a demo project for R&D to diagnose this, I discovered what can trigger this behavior.

When you create your EventFilter, you need to at least set the Conditions property to an empty array of type Condition. If you do not set this property, or you set it to null, you will not see new events after the initial call to GetSessionEventLines().

When I set the Condition property to an empty array, I see new events as expected.

I’ve reported this back to R&D and hopefully a future version of the SDK will make the behavior consistent between GetSessionAlarmLines and GetSessionEventLines.

Hi Joshua

Great, it works. Who expects something like that ? :wink:

Thank you

The Event Server has now been patched to properly handle null Conditions property in the filter for GetSessionEventLines so it will be handled better in 2020 R2 out of the box (too late to add a change for 2020 R1). For 2019 R3 a patch has been added to the cumulative hotfixes here.

Perfect - Thank you