项目场景
跨服务调用报错:feign.RetryableException:xxx executing POST
源码
当Response被认为是可重试时会引发此异常,通常在状态为503时通过feign.codec.ErrorDecoder进行
public class RetryableException extends FeignException {
private static final long serialVersionUID = 1L;
private final Long retryAfter;
private final HttpMethod httpMethod;
/**
* @param retryAfter usually corresponds to the {@link feign.Util#RETRY_AFTER} header.
*/
public RetryableException(int status, String message, HttpMethod httpMethod, Throwable cause,
Date retryAfter, Request request) {
super(status, message, request, cause);
this.httpMethod = httpMethod;
this.retryAfter = retryAfter != null ? retryAfter.getTime() : null;
}
/**
* @param retryAfter usually corresponds to the {@link feign.Util#RETRY_AFTER} header.
*/
public RetryableException(int status, String message, HttpMethod httpMethod, Date retryAfter,
Request request) {
super(status, message, request);
this.httpMethod = httpMethod;
this.retryAfter = retryAfter != null ? retryAfter.getTime() : null;
}
/**
* Sometimes corresponds to the {@link feign.Util#RETRY_AFTER} header present in {@code 503}
* status. Other times parsed from an application-specific response. Null if unknown.
*/
public Date retryAfter() {
return retryAfter != null ? new Date(retryAfter) : null;
}
public HttpMethod method() {
return this.httpMethod;
}
}
FeignClientProperties的config属性
FeignClientProperties是Feign客户端的配置类,对应我们在yml中的feign.client。我们可以通过配置connectTimeout和readTimeout的大戏
解决方案
方案一
feign:
client:
config:
default:
connectTimeout: 60000
readTimeout: 60000
方案二
运维重置ip解析
总结三个原因
①开发和运维真的要沟通清除(我们遇到这个问题原因就是开发以为运维配置了,运维觉得如果需要配置,开发会和他沟通)
②看日志一定要仔细(当时运维把报错日志发给我时,真没仔细看,直接就干百度,结果浪费了不少时间)