connect

external fun connect(authority: String, listener: (session: ClientHttp2Session, socket: Any) -> Unit): ClientHttp2Session(source)
external fun connect(authority: <Error class: unknown class>, listener: (session: ClientHttp2Session, socket: Any) -> Unit): ClientHttp2Session(source)

Returns a ClientHttp2Session instance.

import http2 from 'node:http2';
const client = http2.connect('https://localhost:1234');

// Use the client

client.close();

Since

v8.4.0

Parameters

authority

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.

listener

Will be registered as a one-time listener of the {@link 'connect'} event.


external fun connect(authority: String): ClientHttp2Session(source)
external fun connect(    authority: String,     options: ClientSessionOptions = definedExternally,     listener: (session: ClientHttp2Session, socket: Any) -> Unit = definedExternally): ClientHttp2Session(source)
external fun connect(    authority: String,     options: SecureClientSessionOptions = definedExternally,     listener: (session: ClientHttp2Session, socket: Any) -> Unit = definedExternally): ClientHttp2Session(source)
external fun connect(authority: <Error class: unknown class>): ClientHttp2Session(source)
external fun connect(    authority: <Error class: unknown class>,     options: ClientSessionOptions = definedExternally,     listener: (session: ClientHttp2Session, socket: Any) -> Unit = definedExternally): ClientHttp2Session(source)
external fun connect(    authority: <Error class: unknown class>,     options: SecureClientSessionOptions = definedExternally,     listener: (session: ClientHttp2Session, socket: Any) -> Unit = definedExternally): ClientHttp2Session(source)