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

元气小坏坏 提交于 2019-12-10 12:52:49

问题


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.

Any help is greatly appreciated.


回答1:


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

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.

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.



来源:https://stackoverflow.com/questions/37787447/getting-java-io-ioexception-an-existing-connection-was-forcibly-closed-by-the

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!