NATS

NATS Check validates connectivity to a NATS server by completing a client connection and NATS protocol handshake.

Usage with Binary

./wait4it -type=nats -h=127.0.0.1 -p=4222 -t=60

With username and password:

./wait4it -type=nats -h=127.0.0.1 -p=4222 -t=60 -u=app -P=secret

With token authentication:

./wait4it -type=nats -h=127.0.0.1 -p=4222 -t=60 -nats-token=MyToken

With TLS (default system trust; no custom CA in v1):

./wait4it -type=nats -h=127.0.0.1 -p=4222 -t=60 -ssl=enable

Usage with Docker

docker run ph4r5h4d/wait4it -type=nats -h=127.0.0.1 -p=4222 -t=60

Environment Variables

VariableDescriptionDefault
W4IT_TYPEThe type of check (set to nats for NATS).-
W4IT_TIMEOUTTimeout in seconds.30
W4IT_HOSTThe host to check.127.0.0.1
W4IT_PORTThe NATS client port (typically 4222).-
W4IT_USERNAMEUsername for NATS user/password authentication.-
W4IT_PASSWORDPassword for NATS user/password authentication.-
W4IT_PASSWORD_FILEFile containing the NATS password.-
W4IT_NATS_TOKENToken for NATS token authentication.-
W4IT_SSL_MODESet to enable or require for TLS (tls://).disable

Command-Line Arguments

ArgumentDescriptionDefault
-typeThe type of check (set to nats).-
-tTimeout in seconds.30
-hThe host to check.127.0.0.1
-pThe NATS client port (typically 4222).-
-uUsername for NATS user/password authentication.-
-PPassword for NATS user/password authentication.-
-PfFile containing the NATS password.-
-nats-tokenToken for NATS token authentication.-
-sslSet to enable or require for TLS.disable

Notes

  • Environment variables override command-line arguments when the corresponding flag is omitted.
  • You must set -p / W4IT_PORT (for example 4222); the global port default is 0, which is invalid for NATS.
  • Token and username/password can both be supplied; the NATS client may use either depending on server configuration.
  • JetStream readiness, NKey/credentials files, and custom TLS CA paths are not supported in this version.

Exit Codes

CodeMeaning
0Connection successful.
1Timed out.
2Validation error or incorrect input.