Kaynağa Gözat

wip:连接中断异常过滤

wangkaiyue 2 yıl önce
ebeveyn
işleme
ce90b44b30
1 değiştirilmiş dosya ile 4 ekleme ve 1 silme
  1. 4 1
      core/proxy/proxyServer.go

+ 4 - 1
core/proxy/proxyServer.go

@@ -74,14 +74,17 @@ var proxyHandler = func(r *ghttp.Request) {
 		// 代理地址存入上下文ctx中
 		gCtx.ServerAddr = proxyAddr.String()
 		router.UpdateGContext(r, gCtx)
-
 		// 捕获异常,若代理出错,则进行重试
 		var hasErr bool
 		errHandel := func(hw http.ResponseWriter, hr *http.Request, err error) {
 			hasErr = true
+			if err.Error() == "context canceled" {
+				return
+			}
 			if i == (errTryTime - 1) {
 				r.SetError(NewErrorWithCode(GATEWAY_PROXY_ERR, fmt.Sprintf("代理异常:%s err:%v \n", gCtx.ServerAddr, err.Error())))
 			}
+			g.Log().Error(r.Context(), "ErrorHandler ", err)
 		}
 		// 代理请求
 		proxyClient.CreateCustomProxyClient(proxyAddr, errHandel).ServeHTTP(r.Response.ResponseWriter, r.Request)