Hunt down java.net.SocketException: No buffer space available

拈花ヽ惹草 提交于 2019-12-01 04:03:19

It certainly sounds like you are leaking Sockets somehow in your app.

  • Check that your code always closes the Sockets it opens ... even in the event of some exception; i.e. do the close in a finally block.
  • If your code uses URL connections, make sure that they get disconnected.
  • I'm not an expert, but should your code close its InitialContext object?

What we tried (and successfully) kill the problem. JAVA - check again every socket we used, register them in some special class if needed
- provide SocketFactory and ServerSocketFactory for every class which open socket itself (for example jboss Connectors)
- check opened files, close them in finally
- URL opens connection too, but if you ask for stream after that, connection is closed together with stream (thanks Stephen).

OS
- use different java (1.5, 1.6, 1.7)
- install new drivers
- use netstat and monitor traffic on background (using scripts, yes win xp can do the scripts pretty nicely). Use advanced packet sniffers (wire shark?) if needed.
- win xp have limit for concurrent connections, check them (google) too
- check again and again for virus and mallware (even on private network!)

After reading the advice offered in this link! I was able to determine that I was using isDisplayed() way too often in too short of a time. Therefore, I placed a 5 millisecond wait between calls to isDisplayed. This fixed my Socket Exception issue.

    for (final WebElement person: persons){
        if (person.isDisplayed()){
            dosomething;
            sleep 5 milliseconds
        }
    }

As stated in the link you should insert a try catch just in case this wait is not long enough.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!