Netty concurrency and "Connection reset by peer"
Ngoc Dao
ngocdaothanh at gmail.com
Mon Oct 24 21:30:49 EDT 2011
Try httperf instead.
On Tue, Oct 25, 2011 at 9:13 AM, lotstyl <lotstyl at fastwebnet.it> wrote:
> Hi, I've built the following simple server, and I'm stress testing it using
> *ab*.
> If I run *ab* making 3000 total request (300 concurrent) it works. If I run
> it again, it shows me:
>
> *apr_socket_connect(): Connection reset by peer (54)*
>
> And If after this error, I try to make a single request with curl without
> restarting the server, it works. If I run again *ab* it shows the same
> error.
>
> It seems to be that it can't handle too many concurrent connections. Below
> the code:
>
> public static void main(String[] args) throws Exception {
>
> ServerBootstrap bootstrap = new ServerBootstrap(
> new NioServerSocketChannelFactory(
> Executors.newCachedThreadPool(),
> Executors.newCachedThreadPool()));
>
> bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
>
> @Override
> public ChannelPipeline getPipeline() throws Exception {
> return Channels.pipeline(new StringEncoder(), new MyServerHandler());
> }
> });
>
> bootstrap.bind(new InetSocketAddress(9090));
> System.out.println("Running");
> }
>
>
> Here is the handler:
>
>
>
> public class MyServerHandler extends SimpleChannelUpstreamHandler {
>
> private static AtomicLong request = new AtomicLong();
>
> @Override
> public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent
> e)
> throws Exception {
> ChannelFuture channelFuture = e.getChannel().write("This is request #" +
> request.incrementAndGet() + "\n");
> channelFuture.addListener(ChannelFutureListener.CLOSE);
> }
>
> @Override
> public void channelDisconnected(ChannelHandlerContext ctx,
> ChannelStateEvent e) throws Exception {
> }
>
> @Override
> public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
> throws Exception {
> System.out.println(e.getCause());
> e.getChannel().close();
> }
>
> }
>
>
> As you see it's very simple, it just shows the total number of requests
> handled.
> Any tips?
>
> Thanks
>
>
> --
> View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Netty-concurrency-and-Connection-reset-by-peer-tp6927082p6927082.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