Skip to content

Cannot use second mDNS browser in addition to NodeAPI's browser (used to search for RegistrationAPIs) #26

@wristdirect

Description

@wristdirect

When the NodeAPI looks for a RegistrationAPI, it creates an mdns-js browser and starts discovery. There seems to be a bug in mdns-js where any new mdns-js browser created after the first will never emit 'update' events; the first browser will be the only one that gets update messages. Also, only the settings used for the first browser are active.

This means you cannot use mdns-js to search for a QueryAPI within the program that you are running the NodeAPI that is searching for a RegistrationAPI. In the example code below, I never see any log saying it has found a query server.

I realize this is a bug in mdns-js, not Ledger, but I know Ledger already has forked mdns-js, so this may be a bug to be fixed there.

Example code:

let ledger = require('nmos-ledger');
let mdns = require('mdns-js');

let ledger_Node = new ledger.Node(null, null, "Ledger Node", "http://127.0.0.1", "LedgerNode");
let ledger_NodeRAMStore = new ledger.NodeRAMStore(ledger_Node);
let ledger_NodeAPI = new ledger.NodeAPI(3000, ledger_NodeRAMStore, "127.0.0.1");

ledger_NodeAPI.init().start(() => {
    let browser = mdns.createBrowser(mdns.tcp('nmos-query'));
    browser.on('ready', () => {
        browser.discover();
    });
    browser.on('update', (data) => {
        if (data.fullname && data.fullname.indexOf('_nmos-query._tcp') >= 0) {
            console.log("Found a query service.", data.fullname, data.txt.length > 0 ? data.txt : "");
        }
    });
    browser.on('error', () => {
        console.error.bind(null, "mDNS Browser error!");
    });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions