Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it correct when connectting to an port with no service listened #2126

Closed
tianyuanzhonglu opened this issue Jan 17, 2014 · 4 comments
Closed

Comments

@tianyuanzhonglu
Copy link

    // Configure the client.
    EventLoopGroup group = new NioEventLoopGroup();
    Bootstrap b = new Bootstrap();
    b.group(group).channel(NioSocketChannel.class)
            .option(ChannelOption.TCP_NODELAY, true)
            .handler(new ChannelInitializer<SocketChannel>() {
                @Override
                public void initChannel(SocketChannel ch) throws Exception {
                    ch.pipeline().addLast(
                            new EchoClientHandler(firstMessageSize));
                }
            });

    // Start the client.
    // no service on port 8000
    b.connect("localhost", 8000).addListener(new ChannelFutureListener() {
        @Override
        public void operationComplete(ChannelFuture future)
                throws Exception {
            // not reached when exception occur
        }
    });

Exception in thread "main" java.net.ConnectException: Connection refused: no further information: localhost/127.0.0.1:7000
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:191)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:241)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:502)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:452)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:346)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:794)
at java.lang.Thread.run(Unknown Source)

@tianyuanzhonglu
Copy link
Author

my mistake, close

@normanmaurer
Copy link
Member

Which version?

Am 17.01.2014 um 08:28 schrieb tianyuanzhonglu notifications@github.com:

// Configure the client.
EventLoopGroup group = new NioEventLoopGroup();
Bootstrap b = new Bootstrap();
b.group(group).channel(NioSocketChannel.class)
        .option(ChannelOption.TCP_NODELAY, true)
        .handler(new ChannelInitializer<SocketChannel>() {
            @Override
            public void initChannel(SocketChannel ch) throws Exception {
                ch.pipeline().addLast(
                        new EchoClientHandler(firstMessageSize));
            }
        });

// Start the client.
// no service on port 8000
b.connect("localhost", 8000).addListener(new ChannelFutureListener() {
    @Override
    public void operationComplete(ChannelFuture future)
            throws Exception {
        // not reached when exception occur
    }
});

Exception in thread "main" java.net.ConnectException: Connection refused: no further information: localhost/127.0.0.1:7000
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:191)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:241)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:502)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:452)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:346)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:794)
at java.lang.Thread.run(Unknown Source)


Reply to this email directly or view it on GitHub.

@normanmaurer
Copy link
Member

What was the mistake?

Am 17.01.2014 um 08:41 schrieb tianyuanzhonglu notifications@github.com:

my mistake, close


Reply to this email directly or view it on GitHub.

@tianyuanzhonglu
Copy link
Author

I shutdown EventLoopGroup too early in another thread, It's my issue.
sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants