From 877e45ccb2178250e24ccab5bb62402fea70f0b9 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 20 Sep 2024 17:22:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4POST/PUT=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E8=B6=85=E6=97=B610s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/utils/fetch/fetch.go | 4 ++-- src/modules/network_element/fetch_link/ne_config.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/framework/utils/fetch/fetch.go b/src/framework/utils/fetch/fetch.go index 008b557a..be7cc07c 100644 --- a/src/framework/utils/fetch/fetch.go +++ b/src/framework/utils/fetch/fetch.go @@ -87,7 +87,7 @@ func Post(url string, data url.Values, headers map[string]string) ([]byte, error // PostJSON 发送 POST 请求,并将请求体序列化为 JSON 格式 func PostJSON(url string, data any, headers map[string]string) ([]byte, error) { client := &http.Client{ - Timeout: 3 * time.Second, // 超时时间 + Timeout: 10 * time.Second, // 超时时间 } jsonData, err := json.Marshal(data) @@ -180,7 +180,7 @@ func PostUploadFile(url string, params map[string]string, file *os.File) ([]byte // PutJSON 发送 PUT 请求,并将请求体序列化为 JSON 格式 func PutJSON(url string, data any, headers map[string]string) ([]byte, error) { client := &http.Client{ - Timeout: 3 * time.Second, // 超时时间 + Timeout: 10 * time.Second, // 超时时间 } jsonData, err := json.Marshal(data) diff --git a/src/modules/network_element/fetch_link/ne_config.go b/src/modules/network_element/fetch_link/ne_config.go index b83cbbec..4695351a 100644 --- a/src/modules/network_element/fetch_link/ne_config.go +++ b/src/modules/network_element/fetch_link/ne_config.go @@ -54,7 +54,7 @@ func NeConfigOMC(neInfo model.NeInfo) (map[string]any, error) { func NeConfigInfo(neInfo model.NeInfo, paramName string) (map[string]any, error) { // 网元参数配置信息 neUrl := fmt.Sprintf("http://%s:%d/api/rest/systemManagement/v1/elementType/%s/objectType/config/%s", neInfo.IP, neInfo.Port, strings.ToLower(neInfo.NeType), paramName) - resBytes, err := fetch.Get(neUrl, nil, 60_000) + resBytes, err := fetch.Get(neUrl, nil, 30_000) if err != nil { logger.Warnf("NeConfigInfo Get \"%s\"", neUrl) logger.Errorf("NeConfigInfo %s", err.Error())