Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wristdirect opened this issue Apr 20, 2017 · 0 comments

Comments

@wristdirect
Copy link

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!");
    });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant