3
votes

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 ?

3
The used hostname/IP is correct and available for the local computer? Can you try the same settings with a server socket just to be sure? - Konrad
You have a socket leak. Possibly also a selector leak. Retrying the bind is pointless. Post your code. - user207421

3 Answers

0
votes

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

0
votes

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.

0
votes

maybe the ip problems got to /etc/hosts and change it to