Skip to content

Commit

Permalink
add cluster connect timeout setting
Browse files Browse the repository at this point in the history
  • Loading branch information
IAFEnvoy committed Jan 25, 2024
1 parent e976342 commit c209ea6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ cluster_secret: ${CLUSTER_SECRET}
sync_interval: 10
# 同步文件时最多打开的连接数量
download_max_conn: 64
# 连接超时限制(秒),网不好就调高点
connect_timeout: 10
# 服务器上行限制
serve_limit:
# 是否启用上行限制
Expand Down
2 changes: 1 addition & 1 deletion cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (cr *Cluster) Enable(ctx context.Context) (err error) {
return
}
logInfo("Sending enable packet")
tctx, cancel := context.WithTimeout(ctx, time.Second*10)
tctx, cancel := context.WithTimeout(ctx, time.Second * time.Duration(config.ConnectTimeout))
data, err := cr.socket.EmitAckContext(tctx, "enable", Map{
"host": cr.host,
"port": cr.publicPort,
Expand Down
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Config struct {
ClusterSecret string `yaml:"cluster_secret"`
SyncInterval int `yaml:"sync_interval"`
DownloadMaxConn int `yaml:"download_max_conn"`
ConnectTimeout int `yaml:"connect_timeout"`
ServeLimit ServeLimitConfig `yaml:"serve_limit"`
Oss OSSConfig `yaml:"oss"`
Hijack HijackConfig `yaml:"hijack_port"`
Expand All @@ -87,6 +88,7 @@ func readConfig() (config Config) {
ClusterSecret: "${CLUSTER_SECRET}",
SyncInterval: 10,
DownloadMaxConn: 64,
ConnectTimeout: 10,
ServeLimit: ServeLimitConfig{
Enable: false,
MaxConn: 16384,
Expand Down
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cluster_id: ${CLUSTER_ID}
cluster_secret: ${CLUSTER_SECRET}
sync_interval: 10
download_max_conn: 64
connect_timeout: 60
serve_limit:
enable: false
max_conn: 0
Expand Down

0 comments on commit c209ea6

Please sign in to comment.