enable discovery with advertisement #2

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
2 participants

discovery is a UDP multicast standard used by many protocols such as ws-discovery and UPnP.

this simple add-on allows collective to advertise its own identity and listen for new identities on the local server / LAN (if UDP multicast is supported).

the code addition provides an enableDiscovery function with option parameter "ttl"
example:

var collective = new Collective({ host: 'localhost', port: 8124 }, all_hosts, function (collective) {
    collective.set('foo.bar', 7);
    var foo_bar = collective.get('foo.bar'); // = 7;
});
collective.enableDiscovery(10000);

this means that collective will listen for new collective nodes and will advertise its own identity every 10sec.

if ttl is not specified, collective will be in listen mode only and will need to advertise itself manually by calling:

collective.advertise(true);

if collective advertises that it is online, the UDP message that is broadcast is:

collective +host:port

if collective advertises that it is offline, the UDP message that is broadcast is:

collective -host:port

does not work with cluster yet since the discoveryServer socket is shared.
however it does work in multiple node processes using child_process.fork.

there is a node core patch on the roadmap for testing with cluster on the following branch (only at this stage):
https://github.com/strongloop/node/tree/udp-cluster-test

then bind the discoveryServer socket using:

discoveryServer.bind(1900, {shared: false}); 
Owner

arch1t3ct commented Apr 9, 2013

Hey,

I'm not familiar with this kind of auto discovery, therefore I will have to look into it to properly understand realization and benefits/downsides (will try this month, no promises though). One thing that stands out, if I understand correctly, that this will not work outside of LAN?

Overall, I think this needs to be thought through from every possible angle before considering an implementation.

of course, I have provided this for your consideration.
you are correct, discovery is valuable only on the local machine and LAN.
I have not employed a discovery protocol standard such as ssdp or oasis since I felt the requirement here is much simpler.
also, you would need to correct the logic on new collective nodes being discovered, I am not as familiar with your object model as you are.

enjoy.

arch1t3ct closed this Nov 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment