java.net.SocketException: No buffer space available (maximum connections reached?): connect

后端 未结 4 615
孤城傲影
孤城傲影 2020-12-09 17:53

Hi I am using Apache HTTP Client 4.0 to upload some files on a server based on HTTPS protocol. The uploaded application is running 24x7. Today suddenly it started to throw t

4条回答
  •  甜味超标
    2020-12-09 18:18

    My guess: you are running out of ports and the issue isn't directly related to your code but to the current state of your server. Too many connections are opened to other machines and this causes the issue.

    What to look for:

    • Is your server under heavy usage that might cause multiple network connections to be opened?
    • The HTTP client documentation recommends to instantiate only one HttpClient and to reuse this instance. They are cases where instantiating multiple HTTP clients and not releasing connections correctly causes network connections to stack and never be closed. Try to httpPost.releaseConnection(). You might also be interested in the HTTP client documentation, chapter 1.1.5, "Ensuring release of low level resources"

提交回复
热议问题