问题
I am running a long time selector test on the windows7 system on the eclipse console.After 12 hours, so much select.open have been done seccessfully times by times, it,the 'selector.open()', suddenly throws the following excetption:
java.io.IOException: Unable to establish loopback connection
at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:125)
at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:69)
at java.security.AccessController.doPrivileged(Native Method)
at sun.nio.ch.PipeImpl.<init>(PipeImpl.java:141)
at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:50)
at java.nio.channels.Pipe.open(Pipe.java:150)
at sun.nio.ch.WindowsSelectorImpl.<init>(WindowsSelectorImpl.java:126)
at sun.nio.ch.WindowsSelectorProvider.openSelector(WindowsSelectorProvider.java:44)
at java.nio.channels.Selector.open(Selector.java:227)
at cn.scut.chiu.weibocrawler.job.JobManager.initIO(JobManager.java:55)
at cn.scut.chiu.weibocrawler.job.JobManager.<init>(JobManager.java:50)
at cn.scut.chiu.weibocrawler.distributed.worker.Worker.doCommandJob(Worker.java:80)
at cn.scut.chiu.weibocrawler.distributed.NodeBase.writeOp(NodeBase.java:186)
at cn.scut.chiu.weibocrawler.distributed.NodeBase.selectOp(NodeBase.java:87)
at cn.scut.chiu.weibocrawler.distributed.worker.Worker.run(Worker.java:63)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:344)
at sun.nio.ch.Net.bind(Net.java:336)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67)
at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:91)
... 15 more
And my question is that what has happened to the program? And how to fix it?
回答1:
Why do you keep creating Selectors? Maybe you're leaking them? In any case you should use one Selector for as long as possible, not keep creating new ones.
来源:https://stackoverflow.com/questions/26310297/java-io-ioexception-unable-to-establish-loopback-connection-java-net-bindexcept