I have a service, and on startup I am trying connect to AlarmClient. But on restarting of the system, it gives an error ":22331/Central/AlarmService2 is unavailable" .
And also I need to register to MessageCommunicationManager.
In order to understand the question, can you elaborate on this question a bit more? It would be great if you could give more detail. Also, can you please explain what you want to achieve with this?
I am working on a windows service application. There I am trying to register message communication for subscribing event details. Also I am trying to connect to alarmClient also. When system restarts, it is giving the error as mentioned above and not able to connect to alarm client and also not able to register for events. But it is working if we debug the code. Only restart of system this issue happens. I need to restart the service again to work these features manually after system restart. Is there any option to wait until event server starts properly after system restart?
How do we know when the XProtect services are ready and we can register for the message communications.?
Let me clarify one thing, what is alarmClient? Are you talking about one of MIP SDK samples (called “Alarm and Event Viewer”) or an application that you made or something else?
What we are essentially looking for is, post login/authentication when can we call the following code.
alarmClientManager = new AlarmClientManager();
alarmClient = alarmClientManager.GetAlarmClient(EnvironmentManager.Instance.MasterSite.ServerId);
The reason I ask is because, we are making this call from a windows service running on the same machine as Milestone XProtect( All services running on same machine). This issue is face during system restart, all services are started together.
We need to know when is the right time to get AlarmClient call.
PS: For the login/authentication we have a retry logic.
bool communicationReady;
var filter = messageCommunication.RegisterCommunicationFilter(new MessageReceiver((m, d, s) => communicationReady = true), new CommunicationIdFilter(MessageCommunication.WhoAreOnlineResponse));
while (!commReady)
{
messageCommunication.TransmitMessage(new Message(MessageCommunication.WhoAreOnlineRequest), null, null, null); // you might need to change the parameters passed on to Message constructor to match to your use case
Thread. Sleep(1000); // wait a bit to avoid flooding with WhoAreOnlineRequest messages
}
messageCommunication.UnRegisterCommunicationFilter(filter);
// at that point, you know that the server is up and you can start the communication