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

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异常。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

机场信息系统研究员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值