Java 如何处理偶尔发生的SocketException:来自服务器的意外文件结尾?

Java 如何处理偶尔发生的SocketException:来自服务器的意外文件结尾?,java,rest,cxf,Java,Rest,Cxf,我有一个调用另一个远程服务的REST服务 大多数时候,沟通都很好,但偶尔,我会遇到 org.apache.cxf.jaxrs.client.ClientWebApplicationException: org.apache.cxf.interceptor.Fault: Could not send Message. org.apache.cxf.interceptor.Fault: Could not send Message. SocketException invoking https:/

我有一个调用另一个远程服务的REST服务

大多数时候,沟通都很好,但偶尔,我会遇到

org.apache.cxf.jaxrs.client.ClientWebApplicationException: 
org.apache.cxf.interceptor.Fault: Could not send Message.
org.apache.cxf.interceptor.Fault: Could not send Message.
SocketException invoking https://url: Unexpected end of file from server
我做了一些调查,发现是远程服务器意外关闭了连接

这真的让我很困惑,因为所有的东西(输入、头等)都是一样的,我只测试了少量的请求,比如(50-100),我尝试了顺序和并行,只有少数会遇到这个问题

为什么会发生这种情况?在这种情况下,我必须要求远程服务器重新配置,还是必须在服务中实现重试模式

有什么提示吗

谢谢

附言

我正在使用

org.apache.cxf.jaxrs.client.WebClient

调用远程服务。如果我切换到HttpClient,会有什么不同吗

我想为我自己的问题添加一条评论。似乎远程服务器设置为在已建立多个连接时拒绝连接。为了解决这个问题,我简单地禁用了Keep Alive,它似乎正在工作。但我不确定它是否是最好的解决方案,因为它可能会为每个请求调用SSL握手,并影响性能