SC 2016 R2 GetAlarmClient error

I’ve created a plugin which takes a list of alarm in Smart Client using AlarmClientManager. In SC 2018R1 it works fine, but when I check on version 2016 R2 (10.1a, build 3514) it’s thrown an exception when creating AlarmClient

var _alarmClientManager = new AlarmClientManager();
alarmClient = _alarmClientManager.GetAlarmClient(EnvironmentManager.Instance.MasterSite.ServerId);

throws

===================================
 
The entry found in AuthenticationManager's CustomTargetNameDictionary for http://{name}:22331/Central/AlarmService does not match the requested identity of VideoOS/{name}:22331. (mscorlib)
 
------------------------------
Program location
 
 
Server stack trace: 
   at System.ServiceModel.Channels.HttpTransportSecurityHelpers.AddIdentityMapping(Uri via, EndpointAddress target)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.PrepareOpen()
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
 
Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
   at VideoOS.Platform.Proxy.AlarmClient.AlarmClientCredentials.OpenClient()
   at VideoOS.Platform.Proxy.AlarmClient.AlarmClientManager.GetAlarmClient(ServerId serverId)
   at SoundIntelClient.Helpers.AlarmHelper.GetAlarmLines()
   at SoundIntelClient.Client.SoundIntelViewItemWpfUserControl.Init()
   at VideoOS.Platform.Client.ViewItemWpfUserControlWinFormsWrapper.Init()
   at VideoOS.RemoteClient.Application.MIP.PlatformContentHolder.Init(String state)

When I copy and paste my code into my other plugin for Management Client(10.1a, build 1375) it works fine. I’ve also checked AlarmEventViewer and it works.

I’m using the same user for MC and SC.

Any tips why it’s not working in SC?

This code is implemented in VideoOS.Platform.dll. Sense it works for Management Client, but not for Smart Client - I would try to copy the VideoOS.Platform.dll from the Management Client folder to the Smart Client folder - and see if that works. Alternatively you could use the latest VideoOS.Platform.dll and place it in the Smart Client 2016R2 folder.

I’ve already copied VideoOS.Platform.dll from 2018 R1 to MC and SC.

I notice one strange thing. When I run this code

var _alarmClientManager = new VideoOS.Platform.Proxy.AlarmClient.AlarmClientManager();
var alarmClient = _alarmClientManager.GetAlarmClient(EnvironmentManager.Instance.MasterSite.ServerId);

in ViewItemWpfUserControl Init() it throws an exception. But when I move this code to PluginDefinition Init() it works. Additionally, when I have this code both in PluginDefinition Init() and ViewItemWpfUserControl init() it suddenly starts working in both places

Can you check if the ServerId you are using is filled when it fails - could be that you construct the AlarmCommand class before all is up and running (Then you get another message)