Skip to content

Instance Method

connect(scheme:host:port:path:query:headers:proxy:proxyPort:proxyHeaders:proxyConnectDeadline:onUpgrade:)

Establish a WebSocket connection via a proxy server.
@preconcurrency func connect(scheme: String, host: String, port: Int, path: String = "/", query: String? = nil, headers: HTTPHeaders = [:], proxy: String?, proxyPort: Int? = nil, proxyHeaders: HTTPHeaders = [:], proxyConnectDeadline: NIODeadline = NIODeadline.distantFuture, onUpgrade: @escaping @Sendable (WebSocket) -> ()) -> EventLoopFuture<Void>

Parameters

scheme

Scheme component of the URI for the origin server.

host

Host component of the URI for the origin server.

port

Port on which to connect to the origin server.

path

Path component of the URI for the origin server.

query

Query component of the URI for the origin server.

headers

Headers to send to the origin server.

proxy

Host component of the URI for the proxy server.

proxyPort

Port on which to connect to the proxy server.

proxyHeaders

Headers to send to the proxy server.

proxyConnectDeadline

Deadline for establishing the proxy connection.

onUpgrade

An escaping closure to be executed after the upgrade is completed by NIOWebSocketClientUpgrader.

Return Value

A future which completes when the connection to the origin server is established.