Git Product home page Git Product logo

netty-http-client's Introduction

Netty HTTP Client

This project is fairly obsolete - there is a good HTTP client in the JDK now. Use it. This project will be maintained for a while yet, due to use of the adjacent HTTP test-harness that uses this library under the hood.


An asynchronous http client in Java, with a clean, callback-based API, using Netty 4.x.

The API is inspired a bit by Node.js http module; it is designed to (mostly) avoid the Future pattern, and do its business via callbacks. Wherever possible we avoid introducing complicated abstractions that try to hide the business of HTTP communication; rather your code can be involved in as much or as little of that as necessary.

You can use it from Maven projects as described here.

Features

  • HTTP and HTTPS
  • Simple support for Basic authentication
  • Optional support for HTTP cookies
  • Easy, typed API for setting headers
  • Fluent builder API for assembling requests
  • Non-blocking, asynchronous
  • Small, low-surface-area API
  • Pluggable support for SSLContext/TrustManagers for HTTPS

Read the javadoc. The header writing/parsing classes come from acteur-util; some URL-related classes are documented here.

To use with Maven, add the Maven repo to your project as described here. Then add groupId com.mastfrog artifactId netty-http-client to your POM file.

This project also comes with a test harness which is easy to integrate with unit tests, with built-in methods to assert that the response is what you expect, e.g.

        harness.get("static/hello.txt").setTimeout(Duration.seconds(1)).go()
                .assertHasContent()
                .assertStatus(OK)
                .assertHasHeader(Headers.LAST_MODIFIED.name())
                .assertHasHeader(Headers.ETAG.name())
                .assertContent("hello world")
                .getHeader(Headers.LAST_MODIFIED);

See the bottom of this document for test harness documentation.

Usage

The first thing you need is an HttpClient:

	HttpClient client = HttpClient.builder().followRedirects().build();

The API is callback-based. While you can block the current thread until a response is received using ResponseFuture.await(), the entire point of an async I/O is defeated if you do that. Asynchronous programming means learning to love callbacks.

There are two ways to pay attention to the results of an HTTP call - you can listen for State objects which exist for every state transition in the process of making a request and handling the response; or you can provide a simpler callback which will be called with the response once it arrives. This looks like

	ResponseFuture h = client
		.get().setURL ( "http://localhost:9333/foo/bar" ))
		.execute ( new ResponseHandler <String> ( String.class ) {

            protected void receive ( HttpResponseStatus status, HttpHeaders headers, String response ) {
                System.out.println ( "Here's the response: '" + response + "'" );
            }
        });

(ResponseHandler has additional methods you can override to detect error responses, timeouts or refused connections)

You'll note the ResponseHandler callback is parameterized on String - you can get your content as a string, byte array, InputStream or Netty ByteBuf. You can also pass other types; Jackson is used to deserialize JSON, and is the default for unknown types (this may fail if Jackson does not know how to serialize it).

The Details

You can get all the details by providing a Receiver<State<?>> when you build a request; there are states for things like Connecting, HeadersReceived; you can even capture every chunk of chunked encoding individually if you want.

        ResponseFuture f = client.get()
                .setURL( "http://localhost:9333/foo/bar" )
                .setBody( "This is a test", MediaType.PLAIN_TEXT_UTF_8)
                .onEvent( new Receiver<State<?>>() {

            public void receive( State<?> state ) {
                System.out.println( "STATE " + state + " " + state.name() + " " + state.get() );
                if ( state.stateType() == StateType.Finished ) {
                    DefaultFullHttpResponse d = (DefaultFullHttpResponse) state.get();
		    //do something
                }
            }

        }).execute();

Status & To-Dos

This is a young library; it works, but it will surely need some polish yet; and Netty 4.x is still changing, including occasional incompatible changes. Here are some things that would be useful to add:

  • Caching on disk or in memory with proper use of If-Modified-Since and If-None-Match headers
  • Zero copy file streaming using Netty's FileRegion
  • Better tests (actually start a local server, etc)

License

MIT license - do what thou wilt, give credit where it's due

Test Harness (netty-http-test-harness)

Alongside this project is the netty-http-test-harness project. It provides a fluent interface for writing tests of an HTTP server. The server can be anything - the Server interface has no particular dependencies (but is implemented in Acteur if you're using that) - it just has start/stop methods and a port property.

The point is to make it very little code or setup to test something.

Basically you construct a TestHarness instance - passing it a Server, a URL for the base URL and a ShutdownHookRegistry (another simple interface, from Giulius. Or to do it the easy way, and use TestHarness.Module and Giulius-Tests as in this example.

Here's an example:

        DateTime helloLastModified = har.get("static/hello.txt").go()
                .assertHasContent()
                .assertStatus(OK)
                .assertHasHeader(Headers.LAST_MODIFIED.name())
                .assertHasHeader(Headers.ETAG.name())
                .assertContent(HELLO_CONTENT)
                .getHeader(Headers.LAST_MODIFIED);

        DateTime aLastModified = har.get("static/another.txt").go()
                .assertStatus(OK)
                .assertHasContent()
                .assertHasHeader(Headers.LAST_MODIFIED.name())
                .assertHasHeader(Headers.ETAG.name())
                .assertContent("This is another file.  It has some data in it.\n")
                .getHeader(Headers.LAST_MODIFIED);

        assertNotNull(helloLastModified);
        assertNotNull(aLastModified);

        har.get("static/hello.txt")
                .addHeader(Headers.IF_MODIFIED_SINCE, helloLastModified)
                .go()
                .assertStatus(NOT_MODIFIED);

        har.get("static/another.txt")
                .addHeader(Headers.IF_MODIFIED_SINCE, aLastModified)
                .go().assertStatus(NOT_MODIFIED);

netty-http-client's People

Contributors

oscarvdbosch avatar timboudreau avatar vitaliy-kuzmich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netty-http-client's Issues

connection reuse issue

Hi,

I am using this library to make multiple http calls to a particular host:port. I have configured the client to use keep alive connections and I also send Connection: keep-alive header in the http request.

public static final HttpClient client = HttpClient.builder().threadCount(32)
.setChannelOption(ChannelOption.SO_KEEPALIVE, true)
.setChannelOption(ChannelOption.SO_REUSEADDR, true)
.setChannelOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.followRedirects().build();

However I see that the sockets opened by my application goes on increasing and connections are in established state.

If I send a header Connection: Close in the http request, the sockets are closed and reponed and hence the number of sockets in established state dont increase. This is as expected.

I think due to some reason, the client library is keeping the connection alive but is unable to reuse that connection. Is there any configuration which I am missing? Or there can be a bug in http client code or netty code?

LEAK: ByteBuf.release() was not called before it's garbage-collected

When I use netty-http-client I found this error,when I modified class ResponseHandler ,the error disappears。I do not know if this is a problem, so I will ask。My English is poor。thankx

add :

io.netty.util.ReferenceCountUtil.release(content);

protected void internalReceive(HttpResponseStatus status, HttpHeaders headers, ByteBuf content) {
try {
if (status.code() > 399) {
onErrorResponse(status, headers, content.readCharSequence(content.readableBytes(), CharsetUtil.UTF_8).toString());
return;
}
MediaType mediaType = null;
if (headers.contains(HttpHeaderNames.CONTENT_TYPE)) {
try {
mediaType = MediaType.parse(headers.get(HttpHeaderNames.CONTENT_TYPE));
} catch (Exception ex) {
//do nothing
}
}
T o = mediaType == null ? marshallers.read(type, content) : marshallers.read(type, content, mediaType);
_doReceive(status, headers, type.cast(o));
} catch (Exception ex) {
content.resetReaderIndex();
try {
String s = Streams.readString(new ByteBufInputStream(content), "UTF-8");
onErrorResponse(HttpResponseStatus.REQUESTED_RANGE_NOT_SATISFIABLE, headers, s);
} catch (IOException ex1) {
ex.addSuppressed(ex1);
}
Exceptions.chuck(ex);
} finally {
//2018-01-24 修改测试
io.netty.util.ReferenceCountUtil.release(content);
latch.countDown();
}
}

HackSimpleChannelPool

Hi,
protected ChannelFuture connectChannel(Bootstrap bs) {
return initializer.connect(bootstrap);
}
—————>
protected ChannelFuture connectChannel(Bootstrap bs) {
return initializer.connect(bs);
}
If I don't change,I will not be able to release channel???

LEAK: ByteBuf.release()

Memory Leak happens when request more then 50 conccurence

2019-09-24 07:46:35.085 ERROR 1 --- [nt event loop 3] io.netty.util.ResourceLeakDetector : LEAK: ByteBuf.release() was not called before it's garbage-collected. See https://netty.io/wiki/reference-counted-objects.html for more information., Recent access records: , Created at:, io.netty.buffer.AbstractByteBufAllocator.compositeDirectBuffer(AbstractByteBufAllocator.java:223), io.netty.buffer.AbstractByteBufAllocator.compositeDirectBuffer(AbstractByteBufAllocator.java:218), io.netty.buffer.AbstractByteBufAllocator.compositeBuffer(AbstractByteBufAllocator.java:193), com.mastfrog.netty.http.client.MessageHandlerImpl$ResponseState.<init>(MessageHandlerImpl.java:118), com.mastfrog.netty.http.client.MessageHandlerImpl.state(MessageHandlerImpl.java:167), com.mastfrog.netty.http.client.MessageHandlerImpl.channelRead(MessageHandlerImpl.java:253), io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374), io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360), io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352), io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102), io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374), io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360), io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352), io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438), io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:328), io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302), io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253), io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374), io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360), io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352), io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1421), io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374), io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360), io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930), io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163), io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:697), io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:632), io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:549), io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:511), io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918), io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74), java.lang.Thread.run(Thread.java:748),

HttpClient.builder().build()

Hi,

I have a query regarding the usage of netty-http-client. I am using this client for making multiple requests. I am doing the following

HttpClient client = HttpClient.builder().build();
client.get().setURL("http://www.google.com").execute(new ResponseHandler(String.class) {

  protected void receive ( HttpResponseStatus status, HttpHeaders headers, String response ) {
    // handle response  
});

Suppose I have to make 1000 requests. Do I need to do the following multiple time?
HttpClient client = HttpClient.builder().build();

Or use it as a singleton object and use it to make all the requests?

Thanks & Regards,
Tanima

Getting issues in case of Redirect URL - control never reached the response handler

Hi,
I wrote a unit test case and tried testing the http client with the redirected url and setting the timeout (setTimeout(Timeout in milliseconds - Duration)). But the control never reached the response handler. I set the timeout to max possible value as well to check if it is a timeout issue, but it was not the case.
After debugging, I found that there is an atomic boolean variable named cancelled which is getting set at a certain point of time which triggers the job to get failed.

It is working perfectly fine in case of url which is not redirecting in nature. It also works fine with the redirected url if I don't set the timeout.

Is this a known issue or am I missing something here? Please help me out in getting this working with a redirected url and a request timeout.

Thanks
Sheron

proxy

are there any way to set the proxy?

http response without content

Hi,

I am using this client to make http requests. There are cases in which I am only interested in headers and not in content of the response. I dont want to use "head" method as not all servers support this methis. I want to use "get" method but once I get the headers I dont want to receive content from the server. Is it possible with this library or any pointers how it can be done using netty.

Thanks & Regards,
Tanima

direct buffers release issue

Hi Tim,

I profiled my application in which I was using this client to make http calls. Direct buffer pool kept on increasing and it reached a limit in which netty was unable to allocate any direct buffer and it threw Out of memory error. I referenced the article http://netty.io/wiki/reference-counted-objects.html and enabled a flag (-Dio.netty.leakDetectionLevel=PARANOID) to check if there are any buffer leaks. Below is the some part of the output which indicated the leak in in http client code:
#5:

    io.netty.buffer.AdvancedLeakAwareByteBuf.getBytes(AdvancedLeakAwareByteBuf.java:223)
    io.netty.buffer.CompositeByteBuf.getBytes(CompositeByteBuf.java:687)
    io.netty.buffer.CompositeByteBuf.getBytes(CompositeByteBuf.java:40)
    io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:677)
    io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:1495)
    io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:40)
    io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:684)
    io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:1490)
    io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:40)
    com.mastfrog.netty.http.client.ResponseHandler.internalReceive(ResponseHandler.java:87)
    com.mastfrog.netty.http.client.MessageHandlerImpl.sendFullResponse(MessageHandlerImpl.java:268)
    com.mastfrog.netty.http.client.MessageHandlerImpl.channelRead(MessageHandlerImpl.java:226)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:182)
    io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:147)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
    io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    java.lang.Thread.run(Thread.java:745)

#4:

    io.netty.buffer.AdvancedLeakAwareByteBuf.slice(AdvancedLeakAwareByteBuf.java:73)
    io.netty.buffer.CompositeByteBuf.addComponent0(CompositeByteBuf.java:173)
    io.netty.buffer.CompositeByteBuf.addComponent(CompositeByteBuf.java:112)
    com.mastfrog.netty.http.client.MessageHandlerImpl$ResponseState.append(MessageHandlerImpl.java:119)
    com.mastfrog.netty.http.client.MessageHandlerImpl.channelRead(MessageHandlerImpl.java:216)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:182)
    io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:147)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
    io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    java.lang.Thread.run(Thread.java:745)

#3:

    io.netty.buffer.AdvancedLeakAwareByteBuf.order(AdvancedLeakAwareByteBuf.java:63)
    io.netty.buffer.CompositeByteBuf.addComponent0(CompositeByteBuf.java:173)
    io.netty.buffer.CompositeByteBuf.addComponent(CompositeByteBuf.java:112)
    com.mastfrog.netty.http.client.MessageHandlerImpl$ResponseState.append(MessageHandlerImpl.java:119)
    com.mastfrog.netty.http.client.MessageHandlerImpl.channelRead(MessageHandlerImpl.java:216)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:182)
    io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:147)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
    io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    java.lang.Thread.run(Thread.java:745)

#2:

    io.netty.buffer.AdvancedLeakAwareByteBuf.release(AdvancedLeakAwareByteBuf.java:45)
    io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:175)
    io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:147)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
    io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    java.lang.Thread.run(Thread.java:745)

#1:

    io.netty.buffer.AdvancedLeakAwareByteBuf.retain(AdvancedLeakAwareByteBuf.java:709)
    io.netty.handler.codec.http.HttpObjectDecoder.decode(HttpObjectDecoder.java:294)
    io.netty.handler.codec.http.HttpClientCodec$Decoder.decode(HttpClientCodec.java:136)
    io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:268)
    io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:168)
    io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:147)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
    io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    java.lang.Thread.run(Thread.java:745)

Created at:
io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:259)
io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:155)
io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:146)
io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:107)
io.netty.channel.AdaptiveRecvByteBufAllocator$HandleImpl.allocate(AdaptiveRecvByteBufAllocator.java:104)
io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:117)
io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
java.lang.Thread.run(Thread.java:745)
[ERROR] 29 May 2015 12:25:34,480 (io.netty.util.ResourceLeakDetector:error:171)
LEAK: ByteBuf.release() was not called before it's garbage-collected.
Recent access records: 0
Created at:
io.netty.buffer.CompositeByteBuf.(CompositeByteBuf.java:60)
io.netty.buffer.AbstractByteBufAllocator.compositeDirectBuffer(AbstractByteBufAllocator.java:191)
io.netty.buffer.AbstractByteBufAllocator.compositeDirectBuffer(AbstractByteBufAllocator.java:186)
io.netty.buffer.AbstractByteBufAllocator.compositeBuffer(AbstractByteBufAllocator.java:161)
com.mastfrog.netty.http.client.MessageHandlerImpl$ResponseState.(MessageHandlerImpl.java:106)
com.mastfrog.netty.http.client.MessageHandlerImpl.state(MessageHandlerImpl.java:135)
com.mastfrog.netty.http.client.MessageHandlerImpl.channelRead(MessageHandlerImpl.java:188)
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:182)
io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:147)
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
java.lang.Thread.run(Thread.java:745)
[ERROR] 29 May 2015 12:25:34,481 (io.netty.util.ResourceLeakDetector:error:171)
LEAK: ByteBuf.release() was not called before it's garbage-collected.
Recent access records: 5
#5:

    io.netty.buffer.AdvancedLeakAwareByteBuf.getBytes(AdvancedLeakAwareByteBuf.java:223)
    io.netty.buffer.CompositeByteBuf.getBytes(CompositeByteBuf.java:687)
    io.netty.buffer.CompositeByteBuf.getBytes(CompositeByteBuf.java:40)
    io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:677)
    io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:1495)
    io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:40)
    io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:684)
    io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:1490)
    io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:40)
    com.mastfrog.netty.http.client.ResponseHandler.internalReceive(ResponseHandler.java:87)
    com.mastfrog.netty.http.client.MessageHandlerImpl.sendFullResponse(MessageHandlerImpl.java:268)
    com.mastfrog.netty.http.client.MessageHandlerImpl.channelRead(MessageHandlerImpl.java:226)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:182)
    io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:147)
    io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
    io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    java.lang.Thread.run(Thread.java:745)

I tried to release the buffers in the http client code but was unable to do it properly. Can you help me fix the issue and give me some pointers for it.

Thanks & Regards,
Tanima

maven failed

compile group: 'com.mastfrog', name: 'netty-http-client', version: '2.5.0'

Failed to resolve: com.mastfrog:mastfrog-parent:2.5.0

org.netbeans.api:org-openide-util:RELEASE80 dependency

failed to retrieve dependencides with gradle;

dependencies {
    compile group: 'com.mastfrog', name: 'netty-http-client', version: '1.6.2'
}
repositories {
    maven {
       url "http://timboudreau.com/builds/plugin/repository/everything/"
    }
}

My Project > com.mastfrog:netty-http-client:1.6.2 > com.mastfrog:url:1.6.2 > Could not find org.netbeans.api:org-openide-util:RELEASE80.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.