A Connection is a high-level representation of a connection to a remote peer that may have been secured by encryption and multiplexed, depending on the configuration of the nodes between which the connection is made.

interface Connection {
    direction: Direction;
    encryption?: string;
    id: string;
    log: Logger;
    multiplexer?: string;
    remoteAddr: Multiaddr;
    remotePeer: PeerId;
    status: ConnectionStatus;
    streams: Stream[];
    tags: string[];
    timeline: ConnectionTimeline;
    transient: boolean;
    abort(err): void;
    close(options?): Promise<void>;
    newStream(protocols, options?): Promise<Stream>;
}

Properties

direction: Direction

Outbound conections are opened by the local node, inbound streams are opened by the remote

encryption?: string

The encryption protocol negotiated for this connection

id: string

The unique identifier for this connection

log: Logger

The connection logger

multiplexer?: string

The multiplexer negotiated for this connection

remoteAddr: Multiaddr

The address of the remote end of the connection

remotePeer: PeerId

The id of the peer at the remote end of the connection

The current status of the connection

streams: Stream[]

A list of open streams on this connection

tags: string[]

A list of tags applied to this connection

Lifecycle times for the connection

transient: boolean

A transient connection is one that is not expected to be open for very long or one that cannot transfer very much data, such as one being used as a circuit relay connection. Protocols need to explicitly opt-in to being run over transient connections.

Methods