You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to print the data received from ServerSentEvent so I added the following line in HttpSseClient example to print out the data but after printing the first event content, I get IllegalReferenceCountException. There seems to be a race condition that data ByteBuf is released before my println.
for (ServerSentEvent event : eventIterable) {
System.out.println(event.contentAsString());
events.add(event);
}
New response received.
HTTP/1.1 200 OK
Transfer-Encoding: chunked
hello 0
Disconnected from the target VM, address: '127.0.0.1:49250', transport: 'socket'
Exception in thread "main" io.netty.util.IllegalReferenceCountException: refCnt: 0
at io.netty.buffer.AbstractByteBuf.ensureAccessible(AbstractByteBuf.java:1183)
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1134)
at io.netty.buffer.PooledUnsafeDirectByteBuf.nioBuffer(PooledUnsafeDirectByteBuf.java:344)
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:962)
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:951)
at io.reactivex.netty.protocol.http.sse.ServerSentEvent.contentAsString(ServerSentEvent.java:128)
at io.reactivex.netty.examples.http.sse.HttpSseClient.readServerSideEvents(HttpSseClient.java:64)
at io.reactivex.netty.examples.http.sse.HttpSseClient.main(HttpSseClient.java:82)
The text was updated successfully, but these errors were encountered:
@hzariv The problem here is that you are accessing the event content outside of the Observable chain. ServerSentEvent is a ByteBufHolder and gets released as soon as the onNext receiving the item returns ( more details on issue #264 ) .
If you want to access the content outside the chain, you should do a .retain() on the event in the chain and then release it once you have read.
I wanted to print the data received from ServerSentEvent so I added the following line in HttpSseClient example to print out the data but after printing the first event content, I get IllegalReferenceCountException. There seems to be a race condition that data ByteBuf is released before my println.
for (ServerSentEvent event : eventIterable) {
System.out.println(event.contentAsString());
events.add(event);
}
New response received.
HTTP/1.1 200 OK
Transfer-Encoding: chunked
hello 0
Disconnected from the target VM, address: '127.0.0.1:49250', transport: 'socket'
Exception in thread "main" io.netty.util.IllegalReferenceCountException: refCnt: 0
at io.netty.buffer.AbstractByteBuf.ensureAccessible(AbstractByteBuf.java:1183)
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1134)
at io.netty.buffer.PooledUnsafeDirectByteBuf.nioBuffer(PooledUnsafeDirectByteBuf.java:344)
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:962)
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:951)
at io.reactivex.netty.protocol.http.sse.ServerSentEvent.contentAsString(ServerSentEvent.java:128)
at io.reactivex.netty.examples.http.sse.HttpSseClient.readServerSideEvents(HttpSseClient.java:64)
at io.reactivex.netty.examples.http.sse.HttpSseClient.main(HttpSseClient.java:82)
The text was updated successfully, but these errors were encountered: