问题描述
频繁出现connect timed out,有时出现 Address already in use,最后抛出No buffer space available (maximum connections reached?): connect是什么问题呢?求解。具体错误信息如下。。 java.net.SocketTimeoutException: connect timed outat java.net.PlainSocketImpl.socketConnect(Native Method)at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)at java.net.Socket.connect(Socket.java:529)at sun.net.NetworkClient.doConnect(NetworkClient.java:158)at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)at sun.net.www.http.HttpClient.New(HttpClient.java:306)at sun.net.www.http.HttpClient.New(HttpClient.java:323)at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:975)at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:916)at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841)at org.wltea.web.util.SimpleHttpClient.post(SimpleHttpClient.java:75)at org.wltea.luci.client.RemoteIndexService.postQueryCommand(RemoteIndexService.java:367)at org.wltea.luci.client.RemoteIndexService.query(RemoteIndexService.java:207)at com.youboy.search.LuciSearchFk.soxggq(LuciSearchFk.java:506)at _s._gy__jsp._jspService(_gy__jsp.java:480)at com.caucho.jsp.JavaPage.service(JavaPage.java:75)at com.caucho.jsp.Page.subservice(Page.java:506)at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)at com.caucho.server.http.Invocation.service(Invocation.java:315)at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:253)at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:170)at com.caucho.server.TcpConnection.run(TcpConnection.java:139)at java.lang.Thread.run(Thread.java:662)java.net.BindException: Address already in use: connectat java.net.PlainSocketImpl.socketConnect(Native Method)at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)at java.net.Socket.connect(Socket.java:529)at sun.net.NetworkClient.doConnect(NetworkClient.java:158)at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)at sun.net.www.http.HttpClient.New(HttpClient.java:306)at sun.net.www.http.HttpClient.New(HttpClient.java:323)at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:975)at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:916)at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841)at org.wltea.web.util.SimpleHttpClient.post(SimpleHttpClient.java:75)at org.wltea.luci.client.RemoteIndexService.postQueryCommand(RemoteIndexService.java:367)at org.wltea.luci.client.RemoteIndexService.query(RemoteIndexService.java:223)at com.youboy.search.LuciSearchFk.soxgc(LuciSearchFk.java:393)at _s._gy__jsp._jspService(_gy__jsp.java:305)at com.caucho.jsp.JavaPage.service(JavaPage.java:75)at com.caucho.jsp.Page.subservice(Page.java:506)at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)at com.caucho.server.http.Invocation.service(Invocation.java:315)at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:253)at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:170)at com.caucho.server.TcpConnection.run(TcpConnection.java:139)at java.lang.Thread.run(Thread.java:662)
解决方案
会不会是你的 ServerSocket 设置了连接最大数,而客户端在连接的时候又规定了连接的最长等待时间?如果这样的话,当服务器的连接数已达最大,而又有客户端想连接的话,在等待指定时间后,应该会报 time out。至于 Address already in use ,估计是你直接杀掉了进程但端口未被释放,从而你再次想使用这个端口的时候就报这个错
解决方案二:
线程连接超时 是不是线程堵塞
解决方案三:
看看你两句话对应的你的类:引用at com.caucho.jsp.JavaPage.service(JavaPage.java:75)at com.caucho.jsp.Page.subservice(Page.java:506)