Skip to content

Commit

Permalink
fix fail connection issue
Browse files Browse the repository at this point in the history
  • Loading branch information
matishsiao committed Sep 10, 2015
1 parent c28c2bf commit e97be24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Binary file modified GoHAProxy
Binary file not shown.
11 changes: 8 additions & 3 deletions forwardServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net"
"strings"
"time"
"log"
)


Expand All @@ -24,16 +25,19 @@ type Client struct {
}

func (fs *ForwardServer) CheckHealth(connType string, uri string) (bool, int) {

if uri == "" {
log.Println("Check health failed:uri is empty.")
return false,0
}
conn, err := net.Dial(connType, uri)
errCode := 0

if err != nil {
errCode = 1
return false, errCode
}

defer conn.Close()


conn.SetReadDeadline(time.Now().Add(5 * time.Second))

Expand All @@ -60,6 +64,7 @@ func (fs *ForwardServer) CheckHealth(connType string, uri string) (bool, int) {
}
break
}
conn.Close()
return true, errCode
}

Expand Down

0 comments on commit e97be24

Please sign in to comment.