0
votes

trying to connect client io.netty.bootstrap.Bootstrap:

ChannelFuture cf = null;
cf = m_bootstrap.connect(new InetSocketAddress(InetAddress
            .getByName("127.0.0.1"), 8084));

in cf, result : java.net.ConnectException: Connection refused: /127.0.0.1:8084 detailed message:

[sun.nio.ch.SocketChannelImpl.checkConnect(Native Method), sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:599), io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:208), io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:287), io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528), io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468), io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382), io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354), io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116), java.lang.Thread.run(Thread.java:695)]

my /etc/hosts file looks like this:

127.0.0.1>--localhost
255.255.255.255>broadcasthost
::1             localhost-
****::1%lo*>localhost
127.0.0.1>--********

Not sure what to do? literally assumed I can pass localhost and port and it should work.

2

2 Answers

0
votes

Are you sure there is something really listing on the port ?

Try:

telnet 127.0.0.1 8084

0
votes

turns out in MAC since the server binds to my IP address and not localhost or 127.0.0.1 it would not accept the the client to connect to localhost/127.0.0.1. It worked fine when I replaced loopback addr with my IP. Strange but guess it is something to do with difference interfaces in MAC. Not sure how Windows would react.