[erlang-bugs] Re: [erlang-questions] epmd leaving ports in TIME_WAIT?

Michael Santos michael.santos@REDACTED
Thu Mar 25 01:25:03 CET 2010


On Tue, Mar 23, 2010 at 06:43:37PM -0400, Nicholas Frechette wrote:
> Yes, I know why my node isn't 'up', my question is why is epmd opening a
> socket to query if a node is up? ie: what does it attempt to connect to?

epmd isn't opening the connection, a distributed erlang node is querying
if a node exists on that host and the port it should connect to for that
node. epmd maps local erlang nodes to a port.

> Said node was never up in epmd's lifetime meaning it shouldn't be a cached
> value or the likes. Supposing it connects to my other epmd process on my
> other computer, why would it not keep it as a permanent tcp connection? It
> also attemps to connect to ports on the same host, not just the other
> computer so i'm a bit curious.
> Is epmd implemented as a soap over an http like protocol where queries are
> made over single use socket connections?

When an erlang node is brought up as a distributed node, it connects
to the local epmd with a persistent TCP connection. If the node dies,
the TCP connection is closed and epmd deregisters the node (the atom
that identifies the node). Queries to epmd about which registered nodes
exist on a host are carried out in a single TCP transaction.

See the comments in epmd_srv.c and:

http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html

epmd_srv.c:

*  To keep track of when registered Erlang nodes are terminated this
*  server keeps the socket open where the request for registration was
*  made.

*  In all but one case there is only one request for each connection made
*  to this server so we can safely close the socket after sending the
*  reply.  The exception is ALIVE_REQ where we keep the connection
*  open without sending any data. When we receive a "close" this is
*  an indication that the Erlang node was terminated. The termination
*  may have been "normal" or caused by a crash. The operating system
*  ensure that the connection is closed either way.




More information about the erlang-bugs mailing list