mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-13 22:45:13 +00:00
refine error handling in retry logic
This commit is contained in:
10 files changed
+33
-35
No files matched your search
@@ -5,7 +5,6 @@ import (
|
||||
"sync"
|
||||
|
||||
"v2ray.com/core/common/errors"
|
||||
"v2ray.com/core/app/log"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/retry"
|
||||
)
|
||||
@@ -73,16 +72,13 @@ func (v *TCPHub) start() {
|
||||
v.accepting = true
|
||||
for v.accepting {
|
||||
var newConn Connection
|
||||
err := retry.ExponentialBackoff(10, 200).On(func() error {
|
||||
err := retry.ExponentialBackoff(10, 500).On(func() error {
|
||||
if !v.accepting {
|
||||
return nil
|
||||
}
|
||||
conn, err := v.listener.Accept()
|
||||
if err != nil {
|
||||
if v.accepting {
|
||||
log.Warning("Internet|Listener: Failed to accept new TCP connection: ", err)
|
||||
}
|
||||
return err
|
||||
return errors.Base(err).Message("Internet|Listener: Failed to accept new TCP connection.")
|
||||
}
|
||||
newConn = conn
|
||||
return nil
|
||||
|
||||
@@ -2,12 +2,12 @@ package websocket
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"v2ray.com/core/app/log"
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/errors"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/transport/internet"
|
||||
"v2ray.com/core/transport/internet/internal"
|
||||
@@ -78,11 +78,11 @@ func wsDial(ctx context.Context, dest v2net.Destination) (net.Conn, error) {
|
||||
|
||||
conn, resp, err := dialer.Dial(uri, nil)
|
||||
if err != nil {
|
||||
var reason string
|
||||
if resp != nil {
|
||||
reason, reasonerr := ioutil.ReadAll(resp.Body)
|
||||
log.Info(string(reason), reasonerr)
|
||||
reason = resp.Status
|
||||
}
|
||||
return nil, err
|
||||
return nil, errors.Base(err).Format("WebSocket|Dialer: Failed to dial to (", uri, "): ", reason)
|
||||
}
|
||||
|
||||
return &wsconn{
|
||||
|
||||
Reference in new issue
Block a user