Closed mcollina closed 7 years ago
This (host not known) happens with a single/unjoined node. The point is that a node doesn't know his host until a JOIN with another host is done. The host indeed is deducted during the JOIN phase from the receiving UDP messages (see: https://github.com/marcopiraccini/sd-swim#join-protocol)
What we could do is:
me
and the host is still unknown, try to identify it (the host will be "wrong" is the node is containerized). This is useful mostly in unit tests. I'm ok if we return 'localhost'
in me
if there is no host, or that we use https://www.npmjs.com/package/network-address in that case.
As we are in unit tests, host
might be ok to be 'localhost'
.
https://www.npmjs.com/package/network-address is a good module, but it takes the first interface found so it's often "wrong". So defaulting to 127.0.0.1
should be the safer choice for running tests.
Added and here the test: https://github.com/marcopiraccini/sd-swim/blob/master/test/sd-swim.js#L189
Thanks!!
otherwise we cannot do: