On this page

C

DTLSSession

History

Represents a DTLS association with a single remote peer.

session.send(data): number
Attributes
data:string | Buffer
The data to send.
Returns:number
The number of bytes written to the DTLS layer.

Send application data to the peer. The data is encrypted by DTLS before being sent over UDP. Can only be called after the handshake completes (session.opened has resolved).

session.close(): Promise
Returns:Promise
Resolves when the session is closed.

Initiates a graceful DTLS shutdown by sending a close_notify alert.

session.destroy(error?): void

Immediately destroys the session without sending close_notify.

Attributes
Resolves with { protocol } when the DTLS handshake completes.
Attributes
Resolves when the session is fully closed.
Returns:Object
{ address, family, port }
Returns:string
The negotiated DTLS protocol version (e.g., 'DTLSv1.2').
Returns:Object
{ name, standardName, version }
Returns:string | undefined
The peer's certificate in PEM format.
Returns:string | undefined
The negotiated ALPN protocol.
Returns:string | undefined
The negotiated SRTP protection profile name.
P

session.stats

History

The statistics collected for this session. Read only. The stats object is live and updated as data flows through the session.

session.exportKeyingMaterial(length, label, context?): Buffer
Attributes
length:number
Number of bytes to export.
label:string
The label for the exported keying material.
context:Buffer
Optional context value.
Returns:Buffer

Exports keying material from the DTLS session, as defined in RFC 5705. This is commonly used with DTLS-SRTP to derive encryption keys for media streams.