@@ -145,9 +145,13 @@ public void InternalExcute(CosRequest cosRequest, CosResult cosResult, QCloudCre
145145 }
146146 catch ( CosServerException serverException )
147147 {
148- // 服务端5xx才重试
149- if ( serverException . statusCode >= 500 && retryIndex < MaxRetry )
148+ // webCode >= 300
149+ if ( retryIndex < MaxRetry && serverException . statusCode >= 300 )
150150 {
151+ if ( serverException . requestId == String . Empty )
152+ {
153+ cosRequest . changeDefaultDomain = true ;
154+ }
151155 InternalExcute ( cosRequest , cosResult , credentialProvider , retryIndex + 1 ) ;
152156 }
153157 else
@@ -157,7 +161,7 @@ public void InternalExcute(CosRequest cosRequest, CosResult cosResult, QCloudCre
157161 }
158162 catch ( CosClientException )
159163 {
160- // 客户端异常都重试
164+ // 客户端异常都重试,如本地文件path写错则报警
161165 if ( retryIndex < MaxRetry )
162166 {
163167 InternalExcute ( cosRequest , cosResult , credentialProvider , retryIndex + 1 ) ;
@@ -170,9 +174,17 @@ public void InternalExcute(CosRequest cosRequest, CosResult cosResult, QCloudCre
170174 }
171175 catch ( Exception ex )
172176 {
173- // 未知异常也重试
174- if ( retryIndex < MaxRetry )
177+ if ( retryIndex < MaxRetry ) //请求超时或者其它异常
175178 {
179+ bool isOperationTimeOu = ex . ToString ( ) . Contains ( "The operation has timed out" ) ;
180+ if ( isOperationTimeOu )
181+ {
182+ cosRequest . operationTimeOutRetry = true ;
183+ }
184+ else
185+ {
186+ cosRequest . changeDefaultDomain = true ;
187+ }
176188 InternalExcute ( cosRequest , cosResult , credentialProvider , retryIndex + 1 ) ;
177189 }
178190 else
@@ -204,7 +216,7 @@ public void InternalExcute(CosRequest cosRequest, CosResult cosResult, QCloudCre
204216 // }
205217 // }
206218
207- public void InternalSchedue ( CosRequest cosRequest , CosResult cosResult , COSXML . Callback . OnSuccessCallback < CosResult > successCallback , COSXML . Callback . OnFailedCallback failCallback , QCloudCredentialProvider credentialProvider )
219+ public void InternalSchedue ( CosRequest cosRequest , CosResult cosResult , COSXML . Callback . OnSuccessCallback < CosResult > successCallback , COSXML . Callback . OnFailedCallback failCallback , QCloudCredentialProvider credentialProvider , int retryIndex = 0 )
208220 {
209221
210222 try
@@ -230,7 +242,7 @@ public void InternalSchedue(CosRequest cosRequest, CosResult cosResult, COSXML.C
230242 }
231243 catch ( CosServerException serverException )
232244 {
233- //throw serverException ;
245+ //throw clientException ;
234246 failCallback ( null , serverException ) ;
235247 }
236248 catch ( CosClientException clientException )
@@ -416,7 +428,6 @@ public override void HandleResponseHeader()
416428 cosResult . httpMessage = Message ;
417429 cosResult . responseHeaders = Headers ;
418430 cosResult . InternalParseResponseHeaders ( ) ;
419-
420431 if ( Code >= 300 )
421432 {
422433 this . Body . ParseStream = PaserServerError ;
@@ -431,9 +442,10 @@ public void PaserServerError(Stream inputStream, string contentType, long conten
431442 {
432443 CosServerException cosServerException = new CosServerException ( cosResult . httpCode , cosResult . httpMessage ) ;
433444 List < string > values ;
434-
445+
435446 Headers . TryGetValue ( "x-cos-request-id" , out values ) ;
436447 cosServerException . requestId = ( values != null && values . Count > 0 ) ? values [ 0 ] : null ;
448+
437449 Headers . TryGetValue ( "x-cos-trace-id" , out values ) ;
438450 cosServerException . traceId = ( values != null && values . Count > 0 ) ? values [ 0 ] : null ;
439451
@@ -452,7 +464,6 @@ public void PaserServerError(Stream inputStream, string contentType, long conten
452464
453465 }
454466 }
455-
456467 throw cosServerException ;
457468 }
458469
0 commit comments