why Netty doesn't bind with public IP address & it binds with 127.0.0.1? -
i got in weird situation , can bind serverbootstrap local ip address when tried public ip address throws exception : exception in thread "main" org.jboss.netty.channel.channelexception: failed bind to: /57.88.173.132:5055
can explain me wrong??? btw im using netty 3.6.1
i changed address not real random numbers port real one
here code
private static final string bind_address = "57.88.173.132"; private static final int port = 5055;
public server() { try { startup(); } catch (ioexception e) { e.printstacktrace(); } } private void startup() throws ioexception { serverbootstrap serbootstrap = new serverbootstrap(new nioserversocketchannelfactory(executors.newcachedthreadpool(),executors.newcachedthreadpool())); serbootstrap.setpipelinefactory(new pipelinefactory()); serbootstrap.bind(new inetsocketaddress(bind_address,port));
here exception thrown
exception in thread "main" org.jboss.netty.channel.channelexception: failed bind to: /57.88.173.132:5055 @ org.jboss.netty.bootstrap.serverbootstrap.bind(serverbootstrap.java:301) @ com.game.server.server.startup(server.java:33) @ com.game.server.server.<init>(server.java:22) @ com.game.server.server.main(server.java:44) caused by: java.net.bindexception: cannot assign requested address: bind @ sun.nio.ch.net.bind0(native method) @ sun.nio.ch.net.bind(unknown source) @ sun.nio.ch.net.bind(unknown source) @ sun.nio.ch.serversocketchannelimpl.bind(unknown source) @ sun.nio.ch.serversocketadaptor.bind(unknown source) @ org.jboss.netty.channel.socket.nio.nioserverboss$registertask.run(nioserverboss.java:193) @ org.jboss.netty.channel.socket.nio.abstractnioselector.processtaskqueue(abstractnioselector.java:367) @ org.jboss.netty.channel.socket.nio.abstractnioselector.run(abstractnioselector.java:291) @ org.jboss.netty.channel.socket.nio.nioserverboss.run(nioserverboss.java:42) @ org.jboss.netty.util.threadrenamingrunnable.run(threadrenamingrunnable.java:108) @ org.jboss.netty.util.internal.deadlockproofworker$1.run(deadlockproofworker.java:42) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source)
this not netty issue.
that's clear java.net.bindexception. cases means port listening other process, detect can use netstat command.
but there few special cases:
note 1 here:
it may related misconfiguration in /etc/hosts. in case, this: 192.168.1.11 localhost instead of 127.0.0.1 localhost
note 2 here:
the error says cannot assign requested address. means need use correct address 1 of network interfaces or 0.0.0.0 accept connections interfaces.
edited.
Comments
Post a Comment