lots of sockets stuck at CLOSE_WAIT state
I've been using http-kit for a large project for about a year. There's nothing too special about the configuration, just one large routes file with lots of GET and POST requests. After running for a about a week I get a java socket exception "Too many open files". Running tomcat7 on apache.
I read about that and that it's a common problem with java, and there're some ways to increase the number of open files (sockets), and sometimes the server leaks sockets, and in principle I should fix my "java" code to close all sockets. But I'm not using java.
Here's how I check: number of open files grows all the time: ls -l /proc/xxxx/fd | wc lsof -p xxxx | wc (xxxx is pid of java process)
Without |wc one can see all the CLOSE_WAIT sockets that are left open. Such as: lrwx------ 1 tomcat7 tomcat7 64 Feb 22 19:23 90 -> socket:[23049313] lrwx------ 1 tomcat7 tomcat7 64 Feb 22 19:23 91 -> socket:[23051067] lrwx------ 1 tomcat7 tomcat7 64 Feb 22 19:23 92 -> socket:[23051578] lrwx------ 1 tomcat7 tomcat7 64 Feb 22 19:23 93 -> socket:[23051997] lrwx------ 1 tomcat7 tomcat7 64 Feb 22 19:23 94 -> socket:[23052445] lrwx------ 1 tomcat7 tomcat7 64 Feb 22 19:23 95 -> socket:[23052694] lrwx------ 1 tomcat7 tomcat7 64 Feb 22 19:23 96 -> socket:[23053042] lrwx------ 1 tomcat7 tomcat7 64 Feb 22 19:23 97 -> socket:[23053470] lrwx------ 1 tomcat7 tomcat7 64 Feb 22 19:23 98 -> socket:[23053851]
Some example code:
Starting the server - standard code: (run-server site-routes { :port bindport :ip bindip })
site routes: (def site-routes (let [ring-defaults-config (assoc-in ring.middleware.defaults/site-defaults [:security :anti-forgery] false )] ;(wrap-context (wrap-defaults (-> routes ring.middleware.keyword-params/wrap-keyword-params ring.middleware.params/wrap-params wrap-exceptions wrap-reload ) ring-defaults-config)))
Maybe something here may be the cause for leaking sockets?
Thanks