0.3.2 • Public • Published


    A NPM package that resolves Mesos service URLs to actual host/port endpoints.


    This package can be installed via running npm install mesosdns-client --save.


    The following options are available:

    • dnsServers: The array of available Mesos DNS servers (IP addresses)
    • mesosTLD: The TLD of Mesos, as defined in the Mesos DNS settings (default .mesos)
    • dnsTimeout: The timeout in milliseconds after which a DNS request is considered as timed out
    • defaultPortIndex: The global default "port index" which should be use (default is 0). Can be useful if querying services with multiple ports. To use the portIndex per call, see the get(serviceName, options, callback) function.
    • strategy: The strategy to choose an endpoint which should be used if there are more then one instances of the service/application. Default is weighted (by DNS prio/weight), or random.
    • healthCheckEnabled: If the health checks should be enabled (default is false). Should be set to true is mesosdns-client is used in a long-running application. This will then trigger recurrent health checks.
    • healthCheckInterval: The health check intervall in milliseconds (default is 10000). Should only be used if healthCheckEnabled is true
    • useEvents: Currently this just enables the displaying of debugging messages from the health checks if set to true (default is false)


    To use the mesosdns-client, the Mesos DNS services have to be deployed (ideally) on each Mesos Slave. For example, if there's a web application deployed via Marathon (called web) on three instances, and Mesos DNS runs on the servers, and, we can use it like this:

    Basic usage

    var MesosDNSClient = require("mesosdns-client");
    var options = {
        dnsServers: ["", "", ""],
        mesosTLD: ".mesos"
    var client = new MesosDNSClient(options);
    client.get("web.marathon.mesos", function(error, addressInfo) {
        if (error) console.log(JSON.stringify(error));
        console.log("The complete addressInfo is: " + JSON.stringify(addressInfo));
        console.log("The endpoint is: " + JSON.stringify(addressInfo.endpoint));

    will print

    The complete addressInfo is: {"hostname":"web.marathon.mesos","endpoint":"","host":"","port":31302,"allEndpoints":[{"port":31302,"host":""},{"port":31205,"host":""},{"port":31695,"host":""}],"took":"18"}
    The endpoint is: ""

    If the requested hostname/service is a basic service, such as leader.mesos, the MesosDNSClient will resolve the A record instead of the SRV record. The output will then look like this:

    {"serviceName": "master.mesos", "endpoint": "", "host": "", "allEndpoints": [{"host":""}, {"host":""}, {"host":""}], "took":"11"}

    Advanced usage

    If you want to query services which open more than one port (i.e. a specific port), you can use the options object of the get() to specify the portIndex property (starting with 0):

    client.get("web.marathon.mesos", { portIndex: 1 }, function(error, addressInfo) {
        if (error) console.log(JSON.stringify(error));
        console.log("The complete addressInfo is: " + JSON.stringify(addressInfo));
        console.log("The endpoint is: " + JSON.stringify(addressInfo.endpoint));

    In this case, the client would return the endpoints for the second port (per instance) which is opened by Marathon.


    npm i mesosdns-client

    DownloadsWeekly Downloads






    Last publish


    • tobilg