xk6-tcp
    Preparing search index...

    Interface ConnectOptions

    Configuration options for establishing a TCP socket connection.

    // Basic connection
    socket.connect({
    port: 8080,
    host: 'api.example.com',
    tags: { service: 'api-server' }
    });

    // Secure TLS connection
    socket.connect({
    port: 443,
    host: 'secure.example.com',
    tls: true,
    tags: { protocol: 'tls' }
    });
    interface ConnectOptions {
        host?: string;
        port: number;
        tags?: Record<string, string>;
        tls?: boolean;
    }
    Index

    Properties

    Properties

    host?: string

    The destination hostname or IP address. Defaults to 'localhost'

    port: number

    The destination port number (1-65535)

    tags?: Record<string, string>

    Optional key-value pairs for metrics collection and logging. These tags will be attached to connection-related metrics.

    This is provided for convenience since tags can also be specified during socket creation via SocketOptions. Tags specified here will override tags with the same name specified when creating the socket.

    tls?: boolean

    Enable TLS/SSL encryption for this connection.

    When enabled, the socket will perform a TLS handshake after establishing the TCP connection. TLS configuration (certificates, verification, cipher suites, etc.) is controlled by k6's standard TLS settings.

    Common use cases:

    • Secure database connections (PostgreSQL, MySQL with TLS)
    • HTTPS requests over raw TCP
    • SMTPS, IMAPS mail protocols
    • Custom secure protocols
    false
    
    // Connect to HTTPS port with TLS
    socket.connect({
    port: 443,
    host: 'api.example.com',
    tls: true
    });