得到"java.io.IOException:远程主机强行关闭了现有连接". [英] Getting "java.io.IOException: An existing connection was forcibly closed by the remote host"

查看:352
本文介绍了得到"java.io.IOException:远程主机强行关闭了现有连接".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在打电话给IBM Cloud BPM.有时通话效果很好,但有时会出现以下错误.

I am making rest call to IBM Cloud BPM. Some times calls are working fine.But sometimes it is giving following error.

java.io.IOException: An existing connection was forcibly closed by the remote host.

java.io.IOException: An existing connection was forcibly closed by the remote host
    at sun.nio.ch.SocketDispatcher.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)

任何人都可以帮助我解决这个问题.

Can any one help me on how to solve this issue.

非常感谢您的帮助.

推荐答案

如果您使用的HTTP客户端打开 与服务器的持久连接 ,服务器偶尔会终止它们.

Such behavior could be explained if the HTTP Client you use opens persistent connections to the server, and the server occasionally terminates them.

通常,每个响应后都会关闭与HTTP服务器的连接.使用HTTP"保持活动",可以保持基础TCP连接处于打开状态,直到满足特定条件为止.这些条件取决于服务器,服务器可以在任意超时或请求数量(只要它将响应返回到当前请求之后)后自由关闭连接.

Normally, the connection to an HTTP server is closed after each response. With HTTP "keep-alive" you keep the underlying TCP connection open until certain criteria are met. What those conditions are depends on the server, which is free to close the connection after an arbitrary timeout or number of requests (just as long as it returns the response to the current request).

当服务器关闭此类连接时,客户端通常会再次将其重新打开,并且根据实现的不同,可能会引发异常或打印警告.

When the server closes such a connection the client usually reopens it again, and depending on implementation, may throw an exception or print a warning.

例如, Vert.x HttpClient (默认情况下会打开持久连接)也会抛出...

For example, Vert.x HttpClient (which opens persistent connections by default) also throws...

java.io.IOException: An existing connection was forcibly closed by the remote host

...当服务器终止它们时.

...when the server terminates them.

这篇关于得到"java.io.IOException:远程主机强行关闭了现有连接".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆