当前位置:网站首页>Feign report 400 processing
Feign report 400 processing
2022-04-23 16:49:00 【InfoQ】
getXxByIds(String Ids)
feign.FeignException$BadRequest: [400] during [POST] to [http...
Problem recurrence
@Slf4j
@RestController
public class SkyController {
@GetMapping("/sky")
public String sky (@RequestParam(required = false) String name) {
log.info(name);
return name;
}
@PostMapping("/deliver")
public String deliver (String packageBox) {
log.info(packageBox);
return packageBox;
}
@PostMapping("/feignPost")
public String feignPost(@RequestParam(name = "name") String name){
log.info(name);
return name;
}
@PostMapping("/feignBody")
public String feignBody(@RequestBody String name){
log.info(name);
return name;
}
}
// gateway The service name
@FeignClient(value = "paw-dogs-sky-service")
public interface SkyFeignClient {
@PostMapping("/deliver")
String deliver (@RequestParam(name = "packageBox") String packageBox);
@PostMapping("/feignPost")
String feignPost(@RequestParam(name = "name") String name);
@PostMapping("/feignBody")
String feignBody(@RequestBody String name);
}
@Slf4j
@SpringBootTest
class SkyFeignClientTest {
@Autowired
SkyFeignClient skyFeignClient;
@Test
void deliver () {
String param = RandomUtil.randomString(10*1024);
log.info(param);
String result = skyFeignClient.deliver(param);
log.info(result);
}
@Test
void feignPost () {
String param = RandomUtil.randomString(10*1024);
log.info(param);
String result = skyFeignClient.feignPost(param);
log.info(result);
}
@Test
void feignBody () {
String param = RandomUtil.randomString(1*1024);
log.info(param);
String result = skyFeignClient.feignBody(param);
log.info(result);
}
}

use postman Direct access to service testing


url Length limit
- browser url Length limit
- Server length limit Such as tomcat Limit , nginx url Limit
- SpringBoot Project length limit
max-http-header-size
Default 8k, Change the service provided sky Configuration of 100*1024 (100k) , Retry the normal service call .
DataSize maxHttpHeaderSize = DataSize.ofKilobytes(8)
server:
port: 8080
max-http-header-size: 102400
Source code analysis
RequestTemplate
Map<String, QueryTemplate> queries = new LinkedHashMap<>()
packageBox--> packageBox={packageBox}
SpringMvcContract
processAnnotationOnClass
processAnnotationOnMethod
processAnnotationsOnParameter
AnnotatedParameterProcessor
RequestParamParameterProcessor
public boolean processArgument(AnnotatedParameterContext context,
Annotation annotation, Method method) {
int parameterIndex = context.getParameterIndex();
Class<?> parameterType = method.getParameterTypes()[parameterIndex];
MethodMetadata data = context.getMethodMetadata();
if (Map.class.isAssignableFrom(parameterType)) {
checkState(data.queryMapIndex() == null,
"Query map can only be present once.");
data.queryMapIndex(parameterIndex);
return true;
}
RequestParam requestParam = ANNOTATION.cast(annotation);
String name = requestParam.value();
checkState(emptyToNull(name) != null,
"RequestParam.value() was empty on parameter %s", parameterIndex);
context.setParameterName(name);
// Encapsulate parameters
Collection<String> query = context.setTemplateParameter(name,
data.template().queries().get(name));
data.template().query(name, query);
return true;
}
SynchronousMethodHandler
executeAndDecode(template, options)
Object executeAndDecode(RequestTemplate template, Options options) throws Throwable {
// Build request
Request request = targetRequest(template);
if (logLevel != Logger.Level.NONE) {
logger.logRequest(metadata.configKey(), logLevel, request);
}
Response response;
long start = System.nanoTime();
try {
// perform http request
response = client.execute(request, options);
...
}
Default
LoadBalancerFeignClient
FeignBlockingLoadBalancerClient
solve
1. Increase the of service providers header Parameters ( More micro services Not very suitable )
2. Change it to requestBody Call the service
summary
RequestTemplate
Request
版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231645272078.html
边栏推荐
- Set the color change of interlaced lines in cells in the sail software and the font becomes larger and red when the number is greater than 100
- Deepinv20 installation MariaDB
- 关于 background-image 渐变gradient()那些事!
- On the security of key passing and digital signature
- Detailed explanation of Niuke - Gloves
- 深入了解3D模型相关知识(建模、材质贴图、UV、法线),置换贴图、凹凸贴图与法线贴图的区别
- Easyexcel reads the geographical location data in the excel table and sorts them according to Chinese pinyin
- 5-minute NLP: text to text transfer transformer (T5) unified text to text task model
- 正则过滤内网地址和网段
- Encapsulating the logging module
猜你喜欢
无线鹅颈麦主播麦手持麦无线麦克风方案应当如何选择
漫画:什么是IaaS、PaaS、SaaS?
Summary according to classification in sail software
Sail soft segmentation solution: take only one character (required field) of a string
【PIMF】OpenHarmony啃论文俱乐部—在ACM Survey闲逛是什么体验
Project framework of robot framework
[pyGame games] how did angry birds, a mobile game that became popular all over the world 10 years ago, dominate the list? Classic return
org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
人脸识别框架之dlib
建站常用软件PhpStudy V8.1图文安装教程(Windows版)超详细
随机推荐
The font of the soft cell changes color
Use if else to judge in sail software - use the title condition to judge
如何用Redis实现分布式锁?
Solution of garbled code on idea console
Idea of batch manufacturing test data, with source code
Introduction to how to set up LAN
LVM与磁盘配额
Encapsulating the logging module
Use case execution of robot framework
无线鹅颈麦主播麦手持麦无线麦克风方案应当如何选择
Dancenn: overview of byte self-developed 100 billion scale file metadata storage system
建站常用软件PhpStudy V8.1图文安装教程(Windows版)超详细
English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)
漫画:什么是IaaS、PaaS、SaaS?
PHP高效读大文件处理数据
G008-hwy-cc-estor-04 Huawei Dorado V6 storage simulator configuration
How to implement distributed locks with redis?
Custom implementation of Baidu image recognition (instead of aipocr)
织梦DEDECMS安全设置指南
阿里研发三面,面试官一套组合拳让我当场懵逼