I am trying to execute a set of 200 curl commands on a remote host using Java. The jar file is deployed on the host and it is run on the remote host.
I am using the following code to do so.
The problem that I am facing is that some of the curl commands when executed, randomly show an error like "java.net.NoRouteToHostException: No route to host (Host unreachable)". I am able to ping the host and access the web interface and it seems to be working fine. There are a bunch of curl commands that I am executing. (About 200). Some of them work perfectly fine. Randomly, some command fails with the exception "java.net.NoRouteToHostException: No route to host (Host unreachable)". Retries may or may not work. The curl commands are spit out on a log. When I notice that a curl command has failed, I copy the curl command and try to manually execute it. It works fine without any error even from another terminal on the same host.
One of the things I noticed was that increasing the wait time increased the chances of a retry working. It is like the garbage collector gets more time to free resources and hence it can execute the command without any errors on a retry. The jsonData that is passed to the function is formed using a complex SQL query and takes a few seconds to process. But all of the resources seem to have been freed after the jsonData is fetched.
I feel like this is a Java problem. Glad for any help in figuring out what is going on.
Thanks!