Skip to content

Type Method

connect(scheme:host:port:path:query:headers:configuration:on:onUpgrade:)

Establish a WebSocket connection.
@preconcurrency static func connect(scheme: String = "ws", host: String, port: Int = 80, path: String = "/", query: String? = nil, headers: HTTPHeaders = [:], configuration: WebSocketClient.Configuration = .init(), on eventLoopGroup: any EventLoopGroup, onUpgrade: @escaping @Sendable (WebSocket) -> ()) -> EventLoopFuture<Void>

Parameters

scheme

Scheme component of the URI for the WebSocket server.

host

Host component of the URI for the WebSocket server.

port

Port on which to connect to the WebSocket server.

path

Path component of the URI for the WebSocket server.

query

Query component of the URI for the WebSocket server.

headers

Headers to send to the WebSocket server.

configuration

Configuration for the WebSocket client.

eventLoopGroup

Event loop group to be used by the WebSocket client.

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 WebSocket server is established.