Skip to content

Commit

Permalink
optimize: set the connection error max retry count to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
nange committed Jul 1, 2024
1 parent 7f4df33 commit 52ed86c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion easyss.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,14 @@ func (ss *Easyss) Pool() easypool.Pool {

func (ss *Easyss) AvailableConn(needPingACK ...bool) (conn net.Conn, err error) {
var pool easypool.Pool
var tryCount = 1
if ss.IsNativeOutboundProto() {
if pool = ss.Pool(); pool == nil {
return nil, errors.New("pool is closed")
}
if pool.Len() > 3 {
tryCount = 3
}
}

pingTest := func(conn net.Conn) (er error) {
Expand Down Expand Up @@ -880,7 +884,7 @@ func (ss *Easyss) AvailableConn(needPingACK ...bool) (conn net.Conn, err error)
return
}

for i := 0; i < 3; i++ {
for i := 0; i < tryCount; i++ {
switch ss.OutboundProto() {
case OutboundProtoHTTP:
conn, err = httptunnel.NewLocalConn(ss.HTTPOutboundClient(), "http://"+ss.ServerAddr(), ss.ServerName())
Expand Down

0 comments on commit 52ed86c

Please sign in to comment.