Some of Connection Keep ESTABLISH for hours,Can any one help?

Trustin Lee (이희승) trustin at gmail.com
Mon Nov 30 17:33:06 EST 2009


Hello Lookis,

I don't think this is related with your implementation.  Perhaps it's
a connectivity or network configuration issue between the client and
the server?

— Trustin Lee, http://gleamynode.net/



On Sun, Nov 29, 2009 at 8:17 PM, Lookis <lookisliu at gmail.com> wrote:
>
> Hello all
> I've got a problem with my statistical server,some of the connection from
> client didn't close up ,and keep ESTABLISH for a very long time.
>
> my server is only for statistics,return "204 No Content" and simply close
> the Channel, every thing is OK on my computer's browse ,when i put it on the
> server and simulate the real visit from internet, most requests work
> fine,only few of the request keeps ESTABLISH status,as time goes by,more and
> more Connection become ESTABLISH until the ulimit was hit
>
> i disconnect the "204 Server" from load balance ,and found the ESTABLISH
> Channel keeps for a very long time(2 hour or 3 or 4...)
>
> is this a bug in my code or in netty?
>
> here is mine
> =============
> @ChannelPipelineCoverage("all")
> public class HttpNoContentServer extends SimpleChannelUpstreamHandler {
>
>    @Override
>    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
> throws Exception {
>        HttpResponse response = new
> DefaultHttpResponse(HttpVersion.HTTP_1_1,
>                HttpResponseStatus.NO_CONTENT);
>        response.addHeader(HttpHeaders.Names.SERVER, "wsep");
>        response.addHeader(HttpHeaders.Names.CONTENT_LENGTH, "0");
>        response.addHeader(HttpHeaders.Names.CONNECTION,
> HttpHeaders.Values.CLOSE);
>        try {
>            ChannelFuture future = e.getChannel().write(response);
>            future.addListener(ChannelFutureListener.CLOSE);
>        } catch (Exception e1) {
>            System.err.println("check throw again?");
>            throw new Exception("my exception", e1);
>        }
>    }
>
>    @Override
>    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
> throws Exception {
>        e.getCause().printStackTrace();
>        try {
>            e.getChannel().close();
>        } catch (Exception e1) {
>            System.err.println("Exception throws when trying to close a
> channel!");
>            e1.printStackTrace();
>            e.getChannel().close();
>            e.getChannel().disconnect();
>        } finally {
>
>        }
>    }
> }
> ==================
> and my server
> ==================
>    public static void main(String[] args) {
>        int port = 8080;
>        if (args.length > 0) {
>            port = Integer.parseInt(args[0]);
>        }
>        // Configure the server.
>        ServerBootstrap bootstrap = new ServerBootstrap(new
> NioServerSocketChannelFactory(Executors
>                .newCachedThreadPool(), Executors.newCachedThreadPool()));
>        // Set up the event pipeline factory.
>        bootstrap.setPipelineFactory(new HttpServerPipelineFactory());
>        bootstrap.bind(new InetSocketAddress(port));
>        System.out.println("Server listen on port:" + port);
>    }
> ===================
> and my factory
> ===================
> public class HttpServerPipelineFactory implements ChannelPipelineFactory {
>
>    public ChannelPipeline getPipeline() throws Exception {
>        ChannelPipeline pipeline = pipeline();
>        pipeline.addLast("decoder", new HttpRequestDecoder());
>        pipeline.addLast("encoder", new HttpResponseEncoder());
>        pipeline.addLast("nocontent", new HttpNoContentServer());
>        return pipeline;
>    }
> }
> ====================
>
> thx.
> --
> View this message in context: http://n2.nabble.com/Some-of-Connection-Keep-ESTABLISH-for-hours-Can-any-one-help-tp4082485p4082485.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>



More information about the netty-users mailing list