pyrlang.dist_proto.epmd_client

The module represents EPMD connection and implements the protocol. EPMD is a daemon application, part of Erlang/OTP which registers Erlang nodes on the local machine and helps nodes finding each other.

Message layouts are in “EPMD Protocol” of erl_dist_protocol; the names are those of OTP 29.

class pyrlang.dist_proto.epmd_client.EPMDClient(port=None)

Bases: Protocol

An EPMD client connection which registers ourselves in EPMD and can do other queries.

host_

The local EPMD is always located on the local host.

port_

The local EPMD’s port.

close()

Closing EPMD connection removes the node from available EPMD nodes list. Safe before connect and when called again.

async connect()

Establish the long running connection to the local EPMD.

Returns:

True

Raises:

EPMDConnectionError – EPMD cannot be reached within EPMD_TIMEOUT seconds

Return type:

bool

async alive2(dist)

Register the node in EPMD (EPMD_ALIVE2_REQ): a hidden node as type 72, a visible one as 77.

Parameters:

dist (distribution.ErlangDistribution) – The distribution object from the node

Returns:

True

Raises:

EPMDConnectionError – EPMD refused the name (it is in use), closed the connection or did not answer in time

Return type:

bool

async static query_node(node_name, port=None)

Query EPMD about the port to the given node.

Parameters:
Returns:

Host (the address EPMD answered on) and port (where the node is), or None if not found

Throws EPMDClientError:

if something is wrong with input

Throws EPMDConnectionError:

if EPMD on that host cannot be reached or answers nonsense, or the node does not speak distribution protocol version 6 (OTP 23 and newer)

Return type:

tuple[str, int] | None

pyrlang.dist_proto.epmd_client.epmd_port()

The EPMD port: ERL_EPMD_PORT if set (as for erl), else 4369.