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

Why NettyHttpConnectClient Use so many NioEventGroups? #32

Closed
qixiaobo opened this issue Mar 14, 2020 · 3 comments
Closed

Why NettyHttpConnectClient Use so many NioEventGroups? #32

qixiaobo opened this issue Mar 14, 2020 · 3 comments

Comments

@qixiaobo
Copy link

In XXL-JOB-ADMIN , we can see a lot of nio group if some error occurs.
For some reasons, we may register some unreachable ip to xxl-job-admin.
In xxl-job-admin, we should invoke XxlRpcReferenceBean
We can see code below

	// do invoke
client.asyncSend(finalAddress, xxlRpcRequest);

In this sense , XXL_RPC may produces a NettyHttpConnectionClient
But this way may not work fine

 public void init(String address, final Serializer serializer, final XxlRpcInvokerFactory xxlRpcInvokerFactory) throws Exception {

        if (!address.toLowerCase().startsWith("http")) {
            address = "http://" + address;	// IP:PORT, need parse to url
        }

        this.address = address;
        URL url = new URL(address);
        this.host = url.getHost();
        int port = url.getPort()>-1?url.getPort():80;


        this.group = new NioEventLoopGroup();
        Bootstrap bootstrap = new Bootstrap();
        bootstrap.group(group)
                .channel(NioSocketChannel.class)
                .handler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel channel) throws Exception {
                        channel.pipeline()
                                /*.addLast(new HttpResponseDecoder())
                                .addLast(new HttpRequestEncoder())*/
                                .addLast(new HttpClientCodec())
                                .addLast(new HttpObjectAggregator(5*1024*1024))
                                .addLast(new NettyHttpClientHandler(xxlRpcInvokerFactory, serializer));
                    }
                })
                .option(ChannelOption.SO_KEEPALIVE, true);
        this.channel = bootstrap.connect(host, port).sync().channel();

        this.serializer = serializer;

        // valid
        if (!isValidate()) {
            close();
            return;
        }

        logger.debug(">>>>>>>>>>> xxl-rpc netty client proxy, connect to server success at host:{}, port:{}", host, port);
    }

I don't think we should use a new NioEventGroup here.

@qixiaobo
Copy link
Author

duplicate to #16

@qixiaobo
Copy link
Author

qixiaobo added a commit to qixiaobo/xxl-rpc that referenced this issue Mar 16, 2020
@qixiaobo qixiaobo changed the title Why NettyHttpConnectClient Use so much NioEventGroup? Why NettyHttpConnectClient Use so many NioEventGroups? Mar 18, 2020
@xuxueli
Copy link
Owner

xuxueli commented Apr 15, 2020

你好,问题已修复并推送master分支,可以pull master体验下。将会跟随下个版本发布。

@xuxueli xuxueli closed this as completed Apr 15, 2020
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