java.net.SocketException異常的可能性分析

來源:互聯網
上載者:User

java.net.SocketException異常的可能性分析

近來在做一個MQ的項目,當部署完畢,運行後每隔兩三天就會down機一次,軟體死了。通過系統日誌分析:

InforSuiteV6.0.0 Build2009042101 started

2010-3-29 15:58:36 ClientCommunicatorAdmin restart

警告: Failed to restart: java.io.IOException: Failed to get a RMI stub: javax.na

ming.CommunicationException [Root exception is java.rmi.ConnectIOException: Exce

ption creating connection to: 127.0.0.1; nested exception is:

        java.net.SocketException: No buffer space available (maximum connections

 reached?): JVM_Bind]

2010-3-29 15:58:36 RMIConnector RMIClientCommunicatorAdmin-doStop

警告: Failed to call the method close():java.rmi.ConnectIOException: Exception c

reating connection to: 10.0.0.2; nested exception is:

        java.net.SocketException: No buffer space available (maximum connections

 reached?): JVM_Bind

2010-3-29 15:58:36 ClientCommunicatorAdmin Checker-run

警告: Failed to check connection: java.net.SocketException: No buffer space avai

lable (maximum connections reached?): JVM_Bind

2010-3-29 15:58:36 ClientCommunicatorAdmin Checker-run

警告: stopping

2010-3-29 15:58:52 ClientCommunicatorAdmin restart

警告: Failed to restart: java.io.IOException: Failed to get a RMI stub: javax.na

ming.CommunicationException [Root exception is java.rmi.ConnectIOException: Exce

ption creating connection to: 127.0.0.1; nested exception is:

        java.net.SocketException: No buffer space available (maximum connections

 reached?): JVM_Bind]

發現拋出了一些Socket異常,這些異常均是由檔案控制代碼使用完畢而引起的。也就是說程式裡面開啟的socket,沒有及時關閉掉。為了進一步尋求支援人員,確認分析是否合理,尋找sun的網站資料:

Chances are you are forgetting to close a socket, a database connection, or some other connection that uses sockets internally. See example program below.
The alternative is that your program (or the sum of all programs running on your computer) really needs a lot of connections. In this case you'll need to find out how to increase the amount of socket buffer space that your operating system allocates. I'd start by googling for instructions. Or maybe you could redesign your program so that it doesn't use so much resources.

Sun的支援人員確認了之前分析的有理。java.net.SocketException異常與socket沒有關閉有關,作業系統有它允許持有的最大檔案控制代碼數,而在網路連接的過程中,每個socket請求都要佔用一個檔案控制代碼資源,如果沒有及時釋放,則可能會耗盡檔案控制代碼資源.

 

所以,及時關閉那些不再使用的socket,能夠合理的解決拋出的java.net.SocketException異常。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.