connect

open suspend override fun connect(peer: Endpoint): Connection(source)

Connects to peer, runs the TLS handshake and returns the secure connection.

Throws

for anything but a coaps+tcp Endpoint.Tcp, and for a port other than 5684 unless TlsClientConfig.allowsAnyPortWithoutAlpn is set; nothing is sent then.

when the server's certificate is refused: not trusted, not naming the host, or refused by the pinner, which its cause says. Other handshake failures throw ktor's TLSException, also an SSLException, and a failure to connect the transport's own IOException.