I'm trying to use RxStreamingHttpClient in my controller to stream 100MB file but Micronaut (v3.10.1) logs an error after starting the transfer:
16:13:20.287 [default-nioEventLoopGroup-1-4] WARN io.netty.util.ReferenceCountUtil - Failed to release a message: PooledSlicedByteBuf(freed)
io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:83)
at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:148)
at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:101)
at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:90)
at io.netty.util.ReferenceCountUtil.safeRelease(ReferenceCountUtil.java:116)
at io.netty.channel.ChannelOutboundBuffer.remove(ChannelOutboundBuffer.java:282)
and curl's output:
nwer@alpha ~/tmp $ curl --location 'http://localhost:8080/binary/test1' -i -o test
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
100 12489 0 12489 0 0 8642 0 --:--:-- 0:00:01 --:--:-- 8678
curl: (18) transfer closed with outstanding read data remaining
Below is a method in my controller:
@Get(value = "/test1", produces = MediaType.APPLICATION_OCTET_STREAM)
Flowable<ByteBuffer<?>> test1() throws MalformedURLException {
URL url = new URL("http://localhost:8085");
HttpClientConfiguration conf = new DefaultHttpClientConfiguration();
conf.setMaxContentLength(2147483647);
RxStreamingHttpClient client = RxStreamingHttpClient.create(url, conf);
return client.dataStream(HttpRequest.GET("/v1/objects/9e3aad86-491c-451c-afbc-98f8c21a6ab8/100MbFile"));
}
What is missing in my implementation? Is this the best way to stream ~100MB files via Micronaut?