Git Product home page Git Product logo

Comments (7)

agnat avatar agnat commented on July 30, 2024

Heh, good question. Not sure if it possible at all. I'll look into it.

On Dec 17, 2012, at 15:33, thunder [email protected] wrote:

Hello, how is it possible to handle a stop/start of hte mDNS daemon (avahi-daemon for me on debian).

In case of daemon stop, the client crash and need to be restarted.

Thx.


Reply to this email directly or view it on GitHub.

from node_mdns.

thunderace avatar thunderace commented on July 30, 2024

It's possible in python for example. Calibre, the e-book library management, handle such thing right. But i don't know how :)

from node_mdns.

agnat avatar agnat commented on July 30, 2024

Well, obviously it's possible. What I meant is: It might not be fixable in mdns. If that's the case I'll report it upstream to the node/libuv guys...

On Dec 17, 2012, at 17:37, thunder [email protected] wrote:

It's possible in python for example. Calibre, the e-book library management, handle such thing right. But i don't know how :)


Reply to this email directly or view it on GitHub.

from node_mdns.

agnat avatar agnat commented on July 30, 2024

Well, for me it doesn't crash. If the daemon is down while creating a browser I get an exception. When the daemon goes down while browsing I get an error event. Both is easy to handle:

var mdns = require('./lib/mdns');

try {
  var b = mdns.createBrowser(mdns.tcp('http'));
} catch (ex) {
  console.log('something bad happened. we better start over.')
}

b.on('error', function(error) {
  console.log('something bad happened. we better start over.')
});
b.start();

The error is a bit vague though. But I can't change that. mdns only forwards what the underlying library reports. However, in case of an unknown error it is probably best to set up a new browser and start over anyway. The only improvement on the mdns side I can think of is to attach the actual error code to the exception/error object. The source code looks a bit like I've tried that already and it probably wasn't that simple. However, I'll give it another try (See #57)...

Tested on ubuntu 11.10, node 0.8.12, mdns 1.0.0.

from node_mdns.

thunderace avatar thunderace commented on July 30, 2024

Sorry you arre right : no crash (i missed to attach the 'error' handler). The solution is to restart the browser/createAdvertisement. I will try this. back soon.

Thx

from node_mdns.

thunderace avatar thunderace commented on July 30, 2024

below code to handle avahi errors :

function createAdvertisement()  {
    try {
        var mdns_txt_record = {
            name: domoConfig.domoConf.svcName,
            port: domoConfig.domoConf.svcPort
    };
    var advert = mdns.createAdvertisement(mdns.tcp(domoConfig.domoConf.svcName) , domoConfig.domoConf.svcPort, {txtRecord: mdns_txt_record});
    advert.on('error', function(error) {
        console.log("advert ERROR ", error);
        setTimeout(createAdvertisement, 30 * 1000);
    });
    advert.start();
    } catch (ex){
        console.log("advert creation ERROR ");
        setTimeout(createAdvertisement, 30 * 1000);
    } 
} 
}

Thx for your help

from node_mdns.

agnat avatar agnat commented on July 30, 2024

You're welcome.

from node_mdns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.