Change timeout

This commit is contained in:
Ryan Cavicchioni 2021-07-11 13:42:22 -05:00
parent d1cc4531aa
commit 7a30b9a5d3
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D

View File

@ -43,16 +43,14 @@ func main() {
for i = 1; ; i++ {
rtt := time.Now()
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel = context.WithTimeout(context.Background(), time.Second)
r, err := c.Ping(ctx, &pb.PingRequest{Data: data, Seq: i})
if err != nil {
log.Printf("could not connect to: %v", err)
time.Sleep(1 * time.Second)
continue
}
// log.Printf("%d characters roundtrip to (%s): seq=%d time=%s", len(r.Data), address, r.Seq, time.Since(rtt))
fmt.Printf("%d bytes from %s: seq=%d time=%s\n", len(r.Data), address, r.Seq, time.Since(rtt))
//log.Printf("Received: %v", r.Data)
time.Sleep(1 * time.Second)
}
}