Jelajahi Sumber

job功能超时时间处理

oyq28 1 Minggu lalu
induk
melakukan
354e1d19d1
1 mengubah file dengan 12 tambahan dan 2 penghapusan
  1. 12 2
      IMCS_CCS/Service/Impl/ApiRequestService.cs

+ 12 - 2
IMCS_CCS/Service/Impl/ApiRequestService.cs

@@ -38,7 +38,7 @@ namespace IMCS.CCS.Service.Impl
                     headerValue = headerKeyValue.Split('=')[1];
                 }
 
-                IFlurlRequest flurlRequest = apiUrl.WithHeader(headerKey, headerValue).WithTimeout(8) ; 
+                IFlurlRequest flurlRequest = apiUrl.WithHeader(headerKey, headerValue).WithTimeout(16) ; 
                 if (flurlRequest == null)
                 {
                     return (false, "flurlRequest 空指针!");
@@ -72,7 +72,7 @@ namespace IMCS.CCS.Service.Impl
                 if (flurResponse == null)
                 {
                     return (false, "flurResponse 空指针!");
-                }
+                }                
 
                 var result = await flurResponse.GetStringAsync();
 
@@ -83,6 +83,16 @@ namespace IMCS.CCS.Service.Impl
 
                 return (true, result);
             }
+            catch (FlurlHttpTimeoutException ex)
+            {                
+                _logger.LogError(ex, $"接口请求超时【ApiRequestService 》RequestAsync】:{ex.Message}");                
+                return (false, ex.Message);
+            }
+            catch (FlurlHttpException ex)
+            {
+                _logger.LogError(ex, $"接口请求失败【ApiRequestService 》RequestAsync】:{ex.Message}");               
+                return (false, ex.Message);
+            }
             catch (Exception ex)
             {
                 _logger.LogError(ex, $"接口请求异常【ApiRequestService 》RequestAsync】:{ex.Message}");