EnvironmentManager.Instance.MasterSite.ServerId.Uri returns localhost only

We have environment setup as per below:

PC-A

  • Management Server
  • Recording Server
  • Clients
  • API Gateway

PC-B

  • Event Server
  • OUR Server Plugin

I am developing a component application which is invoked by the running on the Event Server machine.

When we tried to get the server URL using the EnvironmentManager.Instance.MasterSite.ServerId.Uri returns http://localhost/ only. Which is eventually resulting in the login failure.

Sample Code chunk:

[STAThread]
static void Main()
{
 
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
 
                    VideoOS.Platform.SDK.Environment.Initialize();          // General initialize.  Always required
                    VideoOS.Platform.SDK.Media.Environment.Initialize();        // Initialize the standalone Environment
 
                    var masterSite = EnvironmentManager.Instance.MasterSite;
                    Uri masterUri = masterSite?.ServerId?.Uri;
                    var currentSite = EnvironmentManager.Instance.CurrentSite;
                    Uri currentUri = currentSite?.ServerId?.Uri;
 
                    DebugLog.WriteLine($"MasterSite uri : {masterUri}");   // Always retuns http://localhost/
                    DebugLog.WriteLine($"CurrentSite uri : {currentUri}"); // Always retuns http://localhost/
 
                        try
                        {
                            
                            VideoOS.Platform.SDK.Environment.AddServer(false, masterUri, masterSite.ServerId?.UserContext?.CredentialCache);                           
                            VideoOS.Platform.SDK.Environment.Login(masterUri);
                           
                            DebugLog.WriteLine($"Login to master site {masterUri}  is success!");
                        }
                        catch (Exception ex)
                        {
                            DebugLog.WriteLine($"Login fail {ex}");                           
                        }
 
 
 }

Output of the above code:

MasterSite uri : http://localhost/

CurrentSite uri : http://localhost/

VideoOS.Platform.SDK.Platform.ServerNotFoundMIPException

at VideoOS.Platform.SDK.EnvironmentService.Login(Uri serverUri, Boolean masterOnly)

at MyProj.Program.Main()

Could you guide us how to get the correct URL for the login or what would be the correct way to login into the system?

The way the MIP SDK works..

At login it gets configuration information from the site it logs in on. Prior to the login it hasn’t communicated with the site and it has no way of delivering any meaningful information pertaining to the site.

You could argue that it is then a mistake that you can read a value from EnvironmentManager.Instance.MasterSite and that it should instead raise an exception when you try.

Given how it works there is no way you can get it to work unless you supply the URL of the Management Server, there is no way for the MIP SDK based application to know this information at initialization.

@Bo Ellegård Andersen (Milestone Systems)​

Please find our scenario below:

PC-A

  • Management Server
  • Recording Server
  • Clients
  • My Client Plugins
  • API Gateway

PC-B

  • Event Server
  • My Server Plugin

My Client Plugin Code – Management Client plugin and Smart Client Search Agent Plugin

 MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
 MessageCommunication messageCommunication = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);
 
 messageCommunication.TransmitMessage(new Message("MYCustomMessageId", jsonRequest), null, null, null);

My Server Plugin - BackgroundPlugin – This will invoke the MyComponentApp - a component application.

private void Run()
{
       ProcessStartInfo info = new ProcessStartInfo("<PATH>/MyComponentApp.exe");
       Process process = new Process();
 
       process.StartInfo = info;
       process.Start();
}

MyComponentApp - a component application

MessageCommunication messageCommunication;
private List<object> msgRef = new List<object>();
[STAThread]
static void Main()
{ 
                  bool isLoggedIn = false;
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
 
                    VideoOS.Platform.SDK.Environment.Initialize();          // General initialize.  Always required
                    VideoOS.Platform.SDK.Media.Environment.Initialize();        // Initialize the standalone Environment
 
                    string hostManagementService = "http://localhost";
                     hostManagementService  = "http://MyManagementServerHOST" ; // Change to Management Server URL
 
                    Uri uri = new UriBuilder(hostManagementService).Uri;
                    VideoOS.Platform.SDK.Environment.AddServer(false, uri, CredentialCache.DefaultNetworkCredentials);
 
                   try
                    {
                        VideoOS.Platform.SDK.Environment.Login(uri);
                       isLoggedIn = true;
                    }
                   catch (Exception ex)
                    {
                        // Remove the Server URL added
                        VideoOS.Platform.SDK.Environment.RemoveServer(uri);
                    }
 
                   if(isLoggedIn)
                 {    
  MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
            messageCommunication = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);
                
 msgRef.Add(messageCommunication.RegisterCommunicationFilter(new MessageReceiver(MYCustomMessageIdHandler),
                        new CommunicationIdFilter("MYCustomMessageId")));
 
                }
 }
  1. Our two major requirements are
    1. Login in component application without showing the login popup
    2. Receive custom message from Client to Component App.
  2. Does above code works if I pass the URL as hostManagementService = “http://MyManagementServerHOST” for a login?
  3. Is there any way to send message thru TransmitMessage from Client Plugin to our MIP Component application - as shown in code above?
    1. MYCustomMessageIdHandler is not called in above code.
  4. Could you guide us how to do it correct way to meet our requirements?

Regards,

Parth Modh

I don’t understand why you would let your Event Server plugin spawn another process, you could simply build your own service and it could use the RunAS for the service for login and it could just run idle if the Event Server doesn’t respond.

If you do a start of a process like you do I can only see that you must deliver both a URL and credentials to the process so that it is capable of logging in.

As far as I can see your code for a login is correct, but it must be fed with the right URL and credentials and I see situations where DefaultNetworkCredentials might not fit.

So I suggest you simplify by doing a service that is started when the server is started like the Event Server is.