java.net.SocketException: Too many open files ?
ulimit
If you know the process IDs (PID) of the specific user you can get the limits for each process with:
cat /proc/<PID>/limits (default for
Max open files seems to be 4096 hard limit)
You can get the number of opened files for each PID with:
ls -1 /proc/<PID>/fd | wc -l
Or /usr/sbin/lsof -u <userName> | wc -l
how-to-fix-javanetsocketexception-too-many-open-files-java-tomcat
urlconnection-leads-too-many-open-files - stackOverflow reference
Make sure to disconnect the connection object
finally {if (con != null) con.disconnect()}
URLConnection or HTTPClient (stackOverflow reference)
con.disconnect()
https://techblog.bozho.net/caveats-of-httpurlconnection/
just for quick reference - copied from above - This is still unclear, but gives us a hint that there’s something more. After reading a couple of stackoverflow and java.net answers (1, 2, 3, 4) and also the android documentation of the same class, which is actually different from the Oracle implementation, it turns out that
.disconnect()
actually closes (or may close, in the case of android) the underlying socket.