• authority {string|URL} The remote HTTP/2 server to connect to. This must be in the form of a minimal, valid URL with the http:// or https:// prefix, host name, and IP port (if a non-default port is used). Userinfo (user ID and password), path, querystring, and fragment details in the URL will be ignored.
    • options {Object}
      • maxDeflateDynamicTableSize {number} Sets the maximum dynamic table size for deflating header fields. Default: 4Kib.
      • maxSettings {number} Sets the maximum number of settings entries per SETTINGS frame. The minimum value allowed is 1. Default: 32.
      • maxSessionMemory{number} Sets the maximum memory that the Http2Session is permitted to use. The value is expressed in terms of number of megabytes, e.g. 1 equal 1 megabyte. The minimum value allowed is 1. This is a credit based limit, existing Http2Streams may cause this limit to be exceeded, but new Http2Stream instances will be rejected while this limit is exceeded. The current number of Http2Stream sessions, the current memory use of the header compression tables, current data queued to be sent, and unacknowledged PING and SETTINGS frames are all counted towards the current limit. Default: 10.
      • maxHeaderListPairs {number} Sets the maximum number of header entries. This is similar to [http.Server#maxHeadersCount][] or [http.ClientRequest#maxHeadersCount][]. The minimum value is 1. Default: 128.
      • maxOutstandingPings {number} Sets the maximum number of outstanding, unacknowledged pings. Default: 10.
      • maxReservedRemoteStreams {number} Sets the maximum number of reserved push streams the client will accept at any given time. Once the current number of currently reserved push streams exceeds reaches this limit, new push streams sent by the server will be automatically rejected. The minimum allowed value is 0. The maximum allowed value is 232-1. A negative value sets this option to the maximum allowed value. Default: 200.
      • maxSendHeaderBlockLength {number} Sets the maximum allowed size for a serialized, compressed block of headers. Attempts to send headers that exceed this limit will result in a 'frameError' event being emitted and the stream being closed and destroyed.
      • paddingStrategy {number} Strategy used for determining the amount of padding to use for HEADERS and DATA frames. Default: http2.constants.PADDING_STRATEGY_NONE. Value may be one of:
        • http2.constants.PADDING_STRATEGY_NONE: No padding is applied.
        • http2.constants.PADDING_STRATEGY_MAX: The maximum amount of padding, determined by the internal implementation, is applied.
        • http2.constants.PADDING_STRATEGY_ALIGNED: Attempts to apply enough padding to ensure that the total frame length, including the 9-byte header, is a multiple of 8. For each frame, there is a maximum allowed number of padding bytes that is determined by current flow control state and settings. If this maximum is less than the calculated amount needed to ensure alignment, the maximum is used and the total frame length is not necessarily aligned at 8 bytes.
      • peerMaxConcurrentStreams {number} Sets the maximum number of concurrent streams for the remote peer as if a SETTINGS frame had been received. Will be overridden if the remote peer sets its own value for maxConcurrentStreams. Default: 100.
      • protocol {string} The protocol to connect with, if not set in the authority. Value may be either 'http:' or 'https:'. Default: 'https:'
      • settings {HTTP/2 Settings Object} The initial settings to send to the remote peer upon connection.
      • createConnection {Function} An optional callback that receives the URL instance passed to connect and the options object, and returns any [Duplex][] stream that is to be used as the connection for this session.
      • …: Any [net.connect()][] or [tls.connect()][] options can be provided.
    • listener {Function} Will be registered as a one-time listener of the ['connect'][] event.
    • Returns: {ClientHttp2Session}

    Returns a ClientHttp2Session instance.

    1. const http2 = require('http2');
    2. const client = http2.connect('https://localhost:1234');
    3. /* Use the client */
    4. client.close();