Skip to content

Commit

Permalink
added timeout to conn factory
Browse files Browse the repository at this point in the history
  • Loading branch information
0xluk committed Mar 1, 2024
1 parent 01e2965 commit d8c7bc6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (cf *connectionFactory) connect() (net.Conn, error) {
return nil, errors.Wrap(err, "getting new random peer")
}
fmt.Printf("connecting to: %s\n", peer)
return net.Dial("tcp", net.JoinHostPort(peer, "21841"))
return net.DialTimeout("tcp", net.JoinHostPort(peer, "21841"), 5*time.Second)
}

type response struct {
Expand Down

0 comments on commit d8c7bc6

Please sign in to comment.