Is the Nx Cloud up? Visit our Status Page for the current health and performance of the Nx Cloud.

Status Page

Retrieve Nx server currently used IP address and port

Answered

Comments

7 comments

  • Andrey Terentyev
    • Network Optix team

    Hello Tiffany,

    You can use the /ec2/getMediaServersEx HTTP API function.
    For example,

    http://localhost:7001/ec2/getMediaServersEx

    The default port number is TCP 7001.

    0
  • Permanently deleted user

    Hi Andrey,

    Thanks for your help.

    Here is another question about the provided solution for our scenario:

    We want to show the customer's Nx server IP address and port number on our plugin UI, under the premise that we cannot sure if our customer had changed the default port number.

    In this case, if we need to know the port number first then use the /ec2/getMediaServersEx HTTP API? Thanks.

    0
  • Andrey Terentyev
    • Network Optix team

    Hi Tiffany,

    The port number can be set by the "port" setting:

    • In Linux in the  /opt/networkoptix/mediaserver/etc/mediaserver.conf file
    • In Windows in the HKEY_LOCAL_MACHINE\SOFTWARE\Network Optix\Network Optix Media Server registry key

    You can read the "port" setting value from the places specified.

    0
  • Permanently deleted user

    Hi Andrey,

    Here is another issue of retrieving IP address via /ec2/getMediaServersEx, that is, we need to know the customer's VMS  server account and password first.

    If there are other possible ways to get the IP address of customer's VMS server to show this information on the plugin UI.

    Thank you.

    0
  • Andrey Terentyev
    • Network Optix team

    Hi,

    > we need to know the customer's VMS server account and password first.

    Yes, you have.

    > If there are other possible ways to get the IP address

    A plugin is loaded into the Server's process. You can use the API of the operating system the Server runs on for determining the Server's local IP addresses.

    0
  • Permanently deleted user

    Hi Andrey,

    Thanks for your reply. IP address can be retrieved via WIN32 API successfully.

    However, we bump into another issue.

     

    The retrieved IP addresses can show on the plugin UI when the string is hardcoded in the Engine::manifestString() as follows.

    std::string Engine::manifestString() const
    {
    return /*suppress newline*/ 1 + (const char*) R"json(
    {
    "deviceAgentSettingsModel": {
    "type": "Settings",
    "items": [
    {
    "type": "ComboBox",
    "name": "httpAddress",
    "caption": "HTTP Address of Nx VMS",
    "defaultValue": ")json" + GetDefaultVMSServerAddress() + R"json(",
    "range": [
    "http://192.168.16.33:7001/", "http://192.168.50.1:7001/", "http://192.168.70.1:7001/"
    ]
    }
    ]
    }
    }
    )json";
    }

    While the string of the IP address list is dynamically generated by another function, it didn't work. The logged value of vms_ip_list is "http://192.168.16.33:7001/", "http://192.168.50.1:7001/", "http://192.168.70.1:7001/".

    std::string Engine::manifestString() const
    {
    return /*suppress newline*/ 1 + (const char*) R"json(
    {
    "deviceAgentSettingsModel": {
    "type": "Settings",
    "items": [
    {
    "type": "ComboBox",
    "name": "httpAddress",
    "caption": "HTTP Address of Nx VMS",
    "defaultValue": ")json" + GetDefaultVMSServerAddress() + R"json(",
    "range": [
    ")json" + GetVMSServerAddressList() + R"json("
    ]
    }
    ]
    }
    }
    )json";
    }

    std::string Engine::GetVMSServerAddressList() const
    {
    if (vms_server_ip_list_->empty())
    GetDefaultVMSServerAddress();

    std::string vms_ip_list;
    for (size_t i = 0; i < vms_server_ip_list_->size(); i++) {
    vms_ip_list += "\"" + vms_server_ip_list_->at(i) + "\"";
    if (i < vms_server_ip_list_->size() - 1)
    vms_ip_list += ", ";
    }
    LOG_I("list %s", vms_ip_list.c_str());
    return vms_ip_list;
    }

     

    If there are some mistakes when we assign generated string and concatenate to Engine::manifestString().

    0
  • Andrey Terentyev
    • Network Optix team

    Hello Tiffany,

    It seems, in this code there are unnecessary quotes

    "range": [
    ")json" + GetVMSServerAddressList() + R"json("
    ]

    The correct code would be

    "range": [
    )json" + GetVMSServerAddressList() + R"json(
    ]
    0

Please sign in to leave a comment.