On this page

    E

    listening

    History
    Attributes
    address:Object

    After calling listen() from a worker, when the 'listening' event is emitted on the server, a 'listening' event will also be emitted on cluster in the primary.

    The event handler is executed with two arguments, the worker contains the worker object and the address object contains the following connection properties: address, port, and addressType. This is very useful if the worker is listening on more than one address.

    cluster.on('listening', (worker, address) => {
      console.log(
        `A worker is now connected to ${address.address}:${address.port}`);
    });

    The addressType is one of:

    • 4 (TCPv4)
    • 6 (TCPv6)
    • -1 (Unix domain socket)
    • 'udp4' or 'udp6' (UDPv4 or UDPv6)