Skip to content

Commit

Permalink
secure-tunnel-server: add timeout to AWS IoT connect (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat authored May 19, 2021
1 parent a217f53 commit 19f9515
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tunnel/cmd/secure-tunnel-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ func main() {
if err != nil {
log.Fatalf("Failed to create MQTT client (%s)", err.Error())
}
if _, err := cli.Connect(context.Background(),

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

if _, err := cli.Connect(ctx,
fmt.Sprintf("secure-tunnel-server-%d", rand.Int()),
mqtt.WithKeepAlive(30),
); err != nil {
Expand Down

0 comments on commit 19f9515

Please sign in to comment.