HTTPs load cause exception in client side

Pankaj Bathwal pankaj.bathwal at agnity.com
Thu Jun 17 03:34:36 EDT 2010


 

I am using Netty 3.1.5 GA on Windows XP SP2 and JDK 1.6

 

I have made a HTTPS Server and HTTPs Client using Netty and now I want to do
some load testing. 

 

My code for load generation is given below;

Rest of the code like "HttpResponseHandler" and other has been copied from
example code "org.jboss.netty.example.http.snoop".

(I can send them if needed)

 

Single request using this client works fine but running multiple request
leads to issue.

After running few requests this load client starts printing some exception
and I don't understand the cause of it.

Please let me know what wrong I am doing in my client code

 

Here is the stack trace of the exception that is printed:

 

java.io.IOException: An established connection was aborted by the software
in your host machine

      at sun.nio.ch.SocketDispatcher.read0(Native Method)

      at sun.nio.ch.SocketDispatcher.read(Unknown Source)

      at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)

      at sun.nio.ch.IOUtil.read(Unknown Source)

      at sun.nio.ch.SocketChannelImpl.read(Unknown Source)

      at
org.jboss.netty.buffer.HeapChannelBuffer.setBytes(HeapChannelBuffer.java:156
)

      at
org.jboss.netty.buffer.AbstractChannelBuffer.writeBytes(AbstractChannelBuffe
r.java:425)

      at
org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:305)

      at
org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.j
ava:275)

      at
org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:196)

      at
org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)

      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

      at java.lang.Thread.run(Unknown Source)

 

 

 

 

 

 

CODE executed in a thread to send HTTPS request in a loop.

 

 

      public synchronized void run()

            {

                  int lCount = 0;

                  while (mShutdown == false && lCount < mExecutionCount)

                  {

                                                

                        try

                        {                 

                        

                          // Configure the client.

                          ClientBootstrap bootstrap = new ClientBootstrap(

                                    mClientSocketFactory);

                          

                          ChannelPipeline pipeline =
bootstrap.getPipeline();

                          

                          SSLEngine engine = 

 
HttpsServerSslContextFactory.getClientContext().createSSLEngine();

                          engine.setUseClientMode(true);

 

 

                          pipeline.addLast("ssl", new SslHandler(engine));

                          pipeline.addLast("decoder", new
HttpResponseDecoder());

                          pipeline.addLast("encoder", new
HttpRequestEncoder());

                          pipeline.addLast("handler", new
HttpResponseHandler(

                                                            lCount, true));

                          

                          // Start the connection attempt.

                          ChannelFuture future = bootstrap.connect(

                                    new InetSocketAddress(mHost, mPort));

                  

                          

                          // Wait until the connection attempt succeeds or
fails.

                          Channel channel =
future.awaitUninterruptibly().getChannel();

 

                          if (!future.isSuccess()) {

                              Thread.sleep(100);

                              ++lCount;

                              continue;

                          }

                          

                          URI uri = new URI(mURL);

                          

                          // Send the HTTP request.

                          HttpRequest request = new DefaultHttpRequest(

                                  HttpVersion.HTTP_1_1, HttpMethod.GET, 

                                  uri.toASCIIString());

                          

                          request.setHeader(HttpHeaders.Names.HOST, mHost);

                          

                          request.setHeader(HttpHeaders.Names.CONNECTION, 

 
HttpHeaders.Values.CLOSE);

                          

                          CookieEncoder httpCookieEncoder = new
CookieEncoder(false);

                          

                          httpCookieEncoder.addCookie("my-cookie", "foo");

                          httpCookieEncoder.addCookie("another-cookie",
"bar");

                          request.setHeader(HttpHeaders.Names.COOKIE, 

 
httpCookieEncoder.encode());

                          

                          ChannelFuture writeChannel =
channel.write(request);

                          

                          writeChannel.awaitUninterruptibly();

                  

                          // Wait for the server to close the connection.

                          channel.getCloseFuture().awaitUninterruptibly();

                          

                          

                        }

                    catch (Exception e)

                        {

                        ++lCount;

                        System.out.println("HTTP Request failed : ");

                        }

                    

                    if (++lCount >= this.mExecutionCount)

                    {

                        break;

                    }

            

                  }

            }

 

Thanks,

Pankaj Bathwal

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20100617/37cb7b3f/attachment-0001.html 


More information about the netty-users mailing list