HTTPs load cause exception in client side
Marc-André Laverdière
marcandre.laverdiere at gmail.com
Thu Jun 17 08:55:57 EDT 2010
I am wondering if not using a separate pipeline factory isn't messing
things up too.
Marc-André LAVERDIÈRE
"Perseverance must finish its work so that you may be mature and
complete, not lacking anything." -James 1:4
mlaverd.theunixplace.com/blog
/"\
\ / ASCII Ribbon Campaign
X against HTML e-mail
/ \
2010/6/17 "이희승 (Trustin Lee)" <trustin at gmail.com>:
> I guess that might be:
>
> http://stackoverflow.com/questions/1477003/an-established-connection-was-aborted-by-the-software-in-your-host-machine
>
> "The connection was being dropped by some switch because the machine
> bandwidth was too high (above the limit)"
>
> Maybe you generated too much traffic and Windows thought your
> application is a worm? :)
>
> Trustin
>
> On 06/17/2010 04:34 PM, Pankaj Bathwal wrote:
>>
>>
>> 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(_AbstractChannelBuffer.java:425_)
>>
>> at
>> org.jboss.netty.channel.socket.nio.NioWorker.read(_NioWorker.java:305_)
>>
>> at
>> org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(_NioWorker.java: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
>>
>>
>>
>>
>>
>
> --
> what we call human nature in actuality is human habit
> http://gleamynode.net/
>
>
> _______________________________________________
> 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