简体   繁体   中英

java.net.BindException: Cannot assign requested address, java.io.IOException: Too many open files

I am getting exception java.net.BindException: Cannot assign requested address, and if this exception occurred I try to bind it again with the same port and host. But after some attempt of bind I am getting java.io.IOException: Too many open files.

Stack Trace:

    java.net.BindException: Cannot assign requested address
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    at sun.nio.ch.SctpServerChannelImpl.bind(SctpServerChannelImpl.java:109)
    at com.sun.nio.sctp.SctpServerChannel.bind(SctpServerChannel.java:184).

and after some failure:

    java.io.IOException: Too many open files
    at sun.nio.ch.IOUtil.makePipe(Native Method)
    at sun.nio.ch.EPollSelectorImpl.<init>(EPollSelectorImpl.java:65)
    at sun.nio.ch.EPollSelectorProvider.openSelector(EPollSelectorProvider.java:36)
    at java.nio.channels.Selector.open(Selector.java:227)

Is it possible that FD remains open when java.net.BindException: Cannot assign requested address ?

This is usually an OS level issue. Look into bumping up the number of files that can be open. On linux the setting is in /etc/security/limits.conf:

UID soft nofile 4096 UID hard nofile 10240

Is it possible that FD remains open when java.net.BindException: Cannot assign requested add?

Yes. You have to close the socket yourself. Clearly you have a socket leak.

I don't see the point of retrying the bind. It will still fail. Probably the original bind problem is also due to a socket leak.

也许ip问题到了/ etc / hosts并将其更改为

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM