当前位置: 代码迷 >> J2SE >> 求教服务器tcp连接数被占满的有关问题
  详细解决方案

求教服务器tcp连接数被占满的有关问题

热度:388   发布时间:2016-04-24 02:25:07.0
求教服务器tcp连接数被占满的问题
服务端tomcat开始后报错,看了一下错误应该是机器TCP连接数被占满的问题,我的程序中有一个while(true) 的循环每3秒执行InetAddress.getByName(macIP).isReachable(timeOut)执行ping两台客户端。另外两台客户端与服务端各有一个socket长连接。服务端有个ibatis的数据库连接池。

服务端程序运行了几天之后,突然出错,InetAddress.getByName(macIP).isReachable(timeOut)执行时IOException异常了。

重启了tomcat也不管用,只好重启了服务器。

我觉得是InetAddress.getByName(macIP).isReachable(timeOut)的问题,但是我测试了几十万次是没有问题的。服务器系统是win2003server。

请教各位,帮忙分析一下。


2011-2-5 9:21:43 org.apache.coyote.http11.Http11BaseProtocol init
严重: Error initializing endpoint
java.net.SocketException: No buffer space available (maximum connections reached?): create
at java.net.ServerSocket.createImpl(ServerSocket.java:255)
at java.net.ServerSocket.getImpl(ServerSocket.java:205)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:141)
at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket

(DefaultServerSocketFactory.java:50)
at org.apache.tomcat.util.net.PoolTcpEndpoint.initEndpoint(PoolTcpEndpoint.java:293)
at org.apache.coyote.http11.Http11BaseProtocol.init(Http11BaseProtocol.java:139)
at org.apache.catalina.connector.Connector.initialize(Connector.java:1017)
at org.apache.catalina.core.StandardService.initialize(StandardService.java:578)
at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:782)
at org.apache.catalina.startup.Catalina.load(Catalina.java:504)
at org.apache.catalina.startup.Catalina.load(Catalina.java:524)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:267)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
2011-2-5 9:21:43 org.apache.catalina.startup.Catalina load
严重: Catalina.start
LifecycleException: Protocol handler initialization failed: java.net.SocketException: No buffer space available 

(maximum connections reached?): create
at org.apache.catalina.connector.Connector.initialize(Connector.java:1019)
at org.apache.catalina.core.StandardService.initialize(StandardService.java:578)
at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:782)
at org.apache.catalina.startup.Catalina.load(Catalina.java:504)
at org.apache.catalina.startup.Catalina.load(Catalina.java:524)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:267)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
2011-2-5 9:21:43 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1000 ms
2011-2-5 9:21:43 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2011-2-5 9:21:43 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/5.5.26
2011-2-5 9:21:43 org.apache.catalina.core.StandardHost start
信息: XML validation disabled
2011-2-5 9:21:45 org.apache.catalina.startup.HostConfig deployWAR
信息: Deploying web application archive HkcSoft2.war
2011-2-5 9:21:52 org.apache.coyote.http11.Http11BaseProtocol start
严重: Error starting endpoint
java.net.SocketException: No buffer space available (maximum connections reached?): create
at java.net.ServerSocket.createImpl(ServerSocket.java:255)
at java.net.ServerSocket.getImpl(ServerSocket.java:205)
  相关解决方案