i got in this weird situation and i can bind ServerBootstrap with local IP address but when i tried with my public IP address it throws an exception : Exception in thread "main" org.jboss.netty.channel.ChannelException: Failed to bind to: /57.88.173.132:5055
can someone explain to me what is wrong??? btw im using netty 3.6.1
i changed the address its not real they are random numbers but the port is real one
here is the 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 is the exception thrown
Exception in thread "main" org.jboss.netty.channel.ChannelException: Failed to bind to: /57.88.173.132:5055
at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:301)
at com.game.server.Server.startup(Server.java:33)
at com.game.server.Server.<init>(Server.java:22)
at com.game.server.Server.main(Server.java:44)
Caused by: java.net.BindException: Cannot assign requested address: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.jboss.netty.channel.socket.nio.NioServerBoss$RegisterTask.run(NioServerBoss.java:193)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:367)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:291)
at org.jboss.netty.channel.socket.nio.NioServerBoss.run(NioServerBoss.java:42)
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)