<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>java.net.SocketException | LogikDevelopment</title>
	<atom:link href="https://www.logikdev.com/tag/java-net-socketexception/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.logikdev.com</link>
	<description>&#34;Il n&#039;y a pas de problème, il n&#039;y a que des solutions. L&#039;esprit de l&#039;homme invente ensuite le problème.&#34; André Gide</description>
	<lastBuildDate>Tue, 25 Apr 2017 13:57:14 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>
	<item>
		<title>Too many open files on Tomcat</title>
		<link>https://www.logikdev.com/2011/12/20/too-many-open-files-on-tomcat/</link>
					<comments>https://www.logikdev.com/2011/12/20/too-many-open-files-on-tomcat/#respond</comments>
		
		<dc:creator><![CDATA[smoreau]]></dc:creator>
		<pubDate>Tue, 20 Dec 2011 00:24:25 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java.net.SocketException]]></category>
		<category><![CDATA[lsof]]></category>
		<category><![CDATA[open file descriptors]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[Too many open files]]></category>
		<category><![CDATA[ulimit]]></category>
		<guid isPermaLink="false">https://www.logikdev.com/?p=1678</guid>

					<description><![CDATA[<p>The other day, one of my websites was not available anymore. Looking at the log files, I found the following exception: Dec 7, 2011 1:22:39 AM org.apache.jk.common.ChannelSocket acceptConnections WARNING: Exception executing accept java.net.SocketException: Too many open files at java.net.PlainSocketImpl.socketAccept(Native Method) at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384) at java.net.ServerSocket.implAccept(ServerSocket.java:450) at java.net.ServerSocket.accept(ServerSocket.java:421) at org.apache.jk.common.ChannelSocket.accept(ChannelSocket.java:307) at org.apache.jk.common.ChannelSocket.acceptConnections(ChannelSocket.java:661) at org.apache.jk.common.ChannelSocket$SocketAcceptor.runIt(ChannelSocket.java:872) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690) at [&#8230;]</p>
<p>The post <a href="https://www.logikdev.com/2011/12/20/too-many-open-files-on-tomcat/">Too many open files on Tomcat</a> first appeared on <a href="https://www.logikdev.com">LogikDevelopment</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>The other day, one of my websites was not available anymore. Looking at the log files, I found the following exception:</p>
<pre>
Dec 7, 2011 1:22:39 AM org.apache.jk.common.ChannelSocket acceptConnections
WARNING: Exception executing accept
java.net.SocketException: Too many open files
	at java.net.PlainSocketImpl.socketAccept(Native Method)
	at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
	at java.net.ServerSocket.implAccept(ServerSocket.java:450)
	at java.net.ServerSocket.accept(ServerSocket.java:421)
	at org.apache.jk.common.ChannelSocket.accept(ChannelSocket.java:307)
	at org.apache.jk.common.ChannelSocket.acceptConnections(ChannelSocket.java:661)
	at org.apache.jk.common.ChannelSocket$SocketAcceptor.runIt(ChannelSocket.java:872)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
	at java.lang.Thread.run(Thread.java:595)
</pre>
<p>This was the first time I was getting this exception. What is even stranger is that I didn&#8217;t change anything on this application for quite a while!<br />
Anyway, I first did what I usually do with Tomcat: restart it! This fixed the issue but only for a few hours before it crashed again.</p>
<p>After some investigation, it seems that Tomcat was reaching the limit of open file descriptors allowed in this machine (1024 in my case).<br />
To get the maximum number of open file descriptors, simply type the following command:</p>
<pre class="brush: bash; light: true; title: ; notranslate">
ulimit -n
</pre>
<p>It is possible to increase this value by editing the file <code>/etc/security/limits.conf</code> and adding the new limit for the user running Tomcat. However, this is not recommended as 1024 should be sufficient.</p>
<p>The second thing I did was to check the list of open files used by the Tomcat process:</p>
<pre class="brush: bash; light: true; title: ; notranslate">
lsof -p 
</pre>
<p>What I found by running this command was a bit odd. It seems that Tomcat was having a multitude of opened connections to one of the web services used by the application. So it looks like the connections between my website and the web service were never closed!  <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f610.png" alt="😐" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
Because I didn&#8217;t change the code on my side, I asked the third party who owns the web service to check their code. I don&#8217;t know what was the root cause of the problem but they fixed it on their side and it is now working fine.</p>
<p><strong>In conclusion, if you get the same exception, try to find where the problem is coming from before increasing the maximum number of open file descriptors.</strong> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p><p>The post <a href="https://www.logikdev.com/2011/12/20/too-many-open-files-on-tomcat/">Too many open files on Tomcat</a> first appeared on <a href="https://www.logikdev.com">LogikDevelopment</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.logikdev.com/2011/12/20/too-many-open-files-on-tomcat/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
