Could not read document: Unexpected EOF read on the socket; nested exception is java.io.EOFException

Posted 爱锅巴

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Could not read document: Unexpected EOF read on the socket; nested exception is java.io.EOFException相关的知识,希望对你有一定的参考价值。

调用接口报错

Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Unexpected EOF read on the socket; nested exception is java.io.EOFException: Unexpected EOF read on the socket

解决方式

调用的接口处的 @RequestBody 改为 @RequestBody(required = false) 即可

出现原因

原因是调用接口没有传Content-Type:application/json

测试

实测如果没有添加required = false会导致调用接口直接报上面错误甚至服务的崩溃,加上required = false如果没传Content-Type:application/json只会让接口无法接收到数据,也不会报错,服务不会崩溃

以上是关于Could not read document: Unexpected EOF read on the socket; nested exception is java.io.EOFException的主要内容,如果未能解决你的问题,请参考以下文章

Could not read document: Unexpected EOF read on the socket; nested exception is java.io.EOFException

Could not read document: Can not deserialize instance of java.lang.String out of START_ARRAY

hexo could not read form 问题

git Could not read from remote repository 解决

Could not read from remote repository.

git: fatal: Could not read from remote repository