NAlexandrov/xk6-tcp

A k6 extension for sending data to TCP port

20

stars

17

commits

Go

primary language

Nov 27, 2025

updated

k6-extension
xk6
Browse cluster: k6 load testing extensions

README

xk6-tcp

A k6 extension for sending strings to TCP port

Build

To build a k6 binary with this plugin, first ensure you have the prerequisites:

Then:

  1. Install xk6:
go install go.k6.io/xk6/cmd/xk6@latest
  1. Build the binary:
xk6 build --with github.com/NAlexandrov/xk6-tcp@latest

Example

import tcp from 'k6/x/tcp';
import { check } from 'k6';

const conn = tcp.connect('host:port');

// Or with timeout 5 seconds
// const conn = tcp.connect('host:port', 5000);

export default function () {
  tcp.writeLn(conn, 'Say Hello');

  // Or with timeout 5 seconds
  // tcp.writeLn(conn, 'Say Hello', 5000);

  let res = String.fromCharCode(...tcp.read(conn, 1024))

  // Or with timeout 5 seconds
  // let res = String.fromCharCode(...tcp.read(conn, 1024, 5000))

  check (res, {
    'verify ag tag': (res) => res.includes('Hello')
  });

  tcp.close(conn);
}

Contributors

NAlexandrov

13 commits

mstoykov

2 commits

koshelev65

1 commits

smalia2001

1 commits

NAlexandrov/xk6-tcp

A k6 extension for sending data to TCP port

20

stars

17

commits

Go

primary language

Nov 27, 2025

updated

k6-extension
xk6
Browse cluster: k6 load testing extensions

README

xk6-tcp

A k6 extension for sending strings to TCP port

Build

To build a k6 binary with this plugin, first ensure you have the prerequisites:

Then:

  1. Install xk6:
go install go.k6.io/xk6/cmd/xk6@latest
  1. Build the binary:
xk6 build --with github.com/NAlexandrov/xk6-tcp@latest

Example

import tcp from 'k6/x/tcp';
import { check } from 'k6';

const conn = tcp.connect('host:port');

// Or with timeout 5 seconds
// const conn = tcp.connect('host:port', 5000);

export default function () {
  tcp.writeLn(conn, 'Say Hello');

  // Or with timeout 5 seconds
  // tcp.writeLn(conn, 'Say Hello', 5000);

  let res = String.fromCharCode(...tcp.read(conn, 1024))

  // Or with timeout 5 seconds
  // let res = String.fromCharCode(...tcp.read(conn, 1024, 5000))

  check (res, {
    'verify ag tag': (res) => res.includes('Hello')
  });

  tcp.close(conn);
}

Contributors

NAlexandrov

13 commits

mstoykov

2 commits

koshelev65

1 commits

smalia2001

1 commits

Languages

Go

100.0%