14

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.

Daniel Grim
  • 2,261
  • 19
  • 22
Rajesh Kohir
  • 191
  • 1
  • 2
  • 7
  • it could mean that, the rest call is not handled properly at other end, or the rest call is not in a proper format. – piyushj Jun 13 '16 at 10:37
  • 1
    That means the server you are trying to communicate with has closed the network connection. Try to find out why it is doing this. Maybe there's a log file on the server somewhere, which might contain an error message that might be useful to find out why this happens. – Jesper Jun 13 '16 at 10:38
  • Piyushj , If rest call is not proper format, it should fail every time.It is passing some times. – Rajesh Kohir Jun 13 '16 at 13:14
  • Jesper, It is a rest call to IBM Cloud BPM.I think, they don't allow me to access the log file.Can I access the Cloud log file? – Rajesh Kohir Jun 13 '16 at 13:16
  • could also be a proxy server/firewall in between that closes the connection – Joram Jun 13 '16 at 13:58
  • Hi Joram, I Disabled the Firwall/Proxy Server for my machine.Still getting same error.Do you think is there any other Issue.Rest calls are working fine from Postman client.Only from java application, I am getting this problem – Rajesh Kohir Jun 22 '16 at 04:28

3 Answers3

13

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.

curd0
  • 2,300
  • 3
  • 27
  • 32
2

I had this error when consuming my API from an outside PC, but when calling from the same PC it worked fine.

To fix to, I went to Control Panel
Right click in Java icon Go to Advanced Tab

Then check Enable Operating System's restricted environment Apply and Save

enter image description here

This fixed my problem.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Roberto Rodriguez
  • 3,179
  • 32
  • 31
  • 2
    Your context is unclear. Did you make this change on the machine serving the API or client machine that was having the disconnect problems? – John L. Stanley Mar 24 '22 at 17:49
0

I have faced same issue on windows server. Then I checked memory utilization of server and it taking more memory so my application is not running. I have singoff some user profile from

Task Manager-->Users Tab--> Right click and Sign Off

This solution worked for me.

Ninja Man
  • 86
  • 3