diff --git a/conn.go b/conn.go index 7d92919..81d432b 100644 --- a/conn.go +++ b/conn.go @@ -307,7 +307,14 @@ func Connect(connStr string, logLevel LogLevel) (conn *Conn, err error) { tcpConn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", params.Host, params.Port)) panicIfErr(err) - panicIfErr(tcpConn.SetDeadline(time.Unix(int64(params.TimeoutSeconds*1000*1000*1000), 0))) + // Handling the timeout using SetDeadline and an absolute date + // 0 if no timeout + noDeadline := time.Time{} + if params.TimeoutSeconds <= 0 { + panicIfErr(tcpConn.SetDeadline(noDeadline)) + } else { + panicIfErr(tcpConn.SetDeadline(time.Now().Add(time.Duration(params.TimeoutSeconds)*time.Second))) + } newConn.tcpConn = tcpConn