Background
In a timed task, the remote interface is called every hour for data synchronization. At first, the implementation method was to call the remote interface in a loop and pass in a single record each time, because each time we need to complete the operation of establishing a connection, data transfer, and disconnection, which is more expensive network and connection resources; later, after testing no problem, we changed to pass in a list for bulk operation after the loop is completed, and then the problem appeared.
10: 12:28.881 [http-nio-8200-exec-3] error c.y.c.s.h. globalexceptionhandler – [handleruntimeexception, 82] – Request Address’/doit ‘, unknown exception occurred org. springframework. http. converter. HttpMessageNotReadableException: JSON parse error: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens; nested exception is com. fasterxml. jackson. core. JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
Environmental information
Version information of openfeign
:
Problem analysis
feign
is configured as follows:
# feign
feign:
sentinel:
enabled: true
okhttp:
enabled: true
httpclient:
enabled: false
client:
config:
default:
connectTimeout: 10000
readTimeout: 10000
compression:
request:
enabled: true
response:
enabled: true
From the configuration, we can understand that the current configuration enables the request and response compression function. We know that when the compression is actually related to the size of the request body, if the requested data body itself is small, it can be transmitted directly without compression, which can save CPU resources for compression; there is a possible reason: compression is a threshold value, more than a certain threshold will be compressed. This can explain the previous question: why is it OK to transfer one piece of data at a time, but there is an error when transferring the list?
Solution:
Just turn compression off.
Note: Due to the change to bulk transfer, the business processing takes longer and errors like “Timed out…” may appear at the request initiation side. The configuration here changes the timeout of HTTP connection from 10s to 60s; when the data synchronization is finished, change it back.
Read More:
- OpenFeign Error: {“code“:1,“msg“:“JSON parse error: Illegal character ((CTRL-CHAR, code 31))
- [Solved] HttpMessageNotReadableException: JSON parse error: Unrecognized field “xxxx“
- [Solved] org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot
- org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deseria
- Feign call Error: duplicate name [How to Solve]
- Microservice call exceptions: error feign.RetryableException: Read timed out executing POST http://xxx…….
- [Solved] Spring integrates canal to call feign error: pool-1-thread-1
- [Solved] JSON parse error: Cannot construct instance of
- [Solved] JSON parse error: Cannot deserialize instance of `java.util.ArrayList<..> out of START_OBJECT token;
- JSON parse error: invalid UTF-8 solution series [How to Solve]
- [Solved] port (127.0.0.1:64444): java.net.SocketException “Interrupted function call: accept failed“
- [Solved] SpringBoot Date Convert Error: JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime`
- [Solved] SpringBoot Error: org.springframework.http.converter.HttpMessageNotReadableException
- [Solved] Arthas failed to bind telnet or http port! Telnet port: 3658, http port: 8563;Error creating bean
- feign.codec.EncodeException: Type definition error: [simple type, class java.util.Collections$3]
- How to Solve SSM JSON Chinese Messy Code Issue
- Feign Error: Load balancer does not have available server for client:XXX
- Error: char cannot be dereferenced [How to Solve]
- Weibo API api Called Error: error:appkey not bind domain! error_code:10017/2/statuses/share.json
- How to Solve Error-SpringCloud-Feign and Sentinel integrate error