Skip to content

TCP UDP

dm03514 edited this page Aug 30, 2018 · 3 revisions

TCP/UDP

$ ./bin/wait-for net --help
NAME:
   wait-for net -

USAGE:
   wait-for net [command options] [arguments...]

OPTIONS:
   --network value, -n value  Protocol: ("tcp", "udp"), any value that go net.Dial accepts (default: "tcp")
   --address value, -a value  address and port ie localhost:8000

Success

# postgres LISTENing on port 5432

$ ./bin/wait-for -t 1s -pi 250ms net -n tcp -a localhost:5432
{"level":"info","msg":"polling","time":"2018-08-30T02:04:45Z"}
{"error":null,"level":"debug","local_addr":{"IP":"127.0.0.1","Port":56850,"Zone":""},"module":"poller.Net","msg":"conn_response","remote_addr":{"IP":"127.0.0.1","Port":5432,"Zone":""},"time":"2018-08-30T02:04:45Z"}
{"err":null,"level":"debug","msg":"poll_result","ready":true,"time":"2018-08-30T02:04:45Z"}
$ echo $?
0

Connection Refused (no socket) Timeout

$ ./bin/wait-for -t 1s -pi 250ms net -n tcp -a localhost:4444
{"level":"info","msg":"polling","time":"2018-08-30T02:03:10Z"}
{"err":"dial tcp 127.0.0.1:4444: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-30T02:03:10Z"}
{"level":"info","msg":"polling","time":"2018-08-30T02:03:10Z"}
{"err":"dial tcp 127.0.0.1:4444: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-30T02:03:10Z"}
{"level":"info","msg":"polling","time":"2018-08-30T02:03:11Z"}
{"err":"dial tcp 127.0.0.1:4444: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-30T02:03:11Z"}
{"level":"info","msg":"polling","time":"2018-08-30T02:03:11Z"}
{"err":"dial tcp 127.0.0.1:4444: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-30T02:03:11Z"}
{"level":"info","msg":"polling","time":"2018-08-30T02:03:11Z"}
{"err":"dial tcp 127.0.0.1:4444: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-30T02:03:11Z"}
{"level":"info","msg":"timeout_reached","time":"2018-08-30T02:03:11Z"}
{"level":"fatal","msg":"timeout reached: 1s","time":"2018-08-30T02:03:11Z"}
$ echo $?
1
Clone this wiki locally