错误信息

A 服务通过Feign调用 B 服务接口,B 服务在收到请求后直接报错如下:

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
 at [Source: java.io.PushbackInputStream@5ee1b7fe; line: 1, column: 2]

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
 at [Source: java.io.PushbackInputStream@5ee1b7fe; line: 1, column: 2]

排查结果

B 服务未开启Gzip支持。

解决方案

方案一

关闭 A 服务Gzip支持:

feign:
 compression:
   request:
     enabled: false
   response:
     enabled: false

方案二

开启 B 服务Gzip支持。此方案待更新...


参考