java.io.IOException: Connection reset by peer at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[na:1.8.0_40] at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[na:1.8.0_40] at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_40] at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[na:1.8.0_40] at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[na:1.8.0_40] at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) ~[netty-buffer-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1054) ~[netty-buffer-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:245) ~[netty-transport-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:106) ~[netty-transport-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:527) [netty-transport-4.1.0.CR7.jar:4.1.0.CR7][error] i.g.n.NettyServerTransport in grpc-default-worker-ELG-14-5 - Transport failedjava.io.IOException: Connection reset by peer at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[na:1.8.0_40] at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[na:1.8.0_40] at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_40] at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[na:1.8.0_40] at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[na:1.8.0_40] at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) ~[netty-buffer-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1054) ~[netty-buffer-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:245) ~[netty-transport-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:106) ~[netty-transport-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:527) [netty-transport-4.1.0.CR7.jar:4.1.0.CR7]
Hello. I am using a StreamObserver to return a stream of response.
I found out that calling StreamObserver's onNext doesn't throw an exception when it fails to send a response.
I was wondering if there is any way that I can catch this exception as soon as I call onNext.
CancellationListener doesn't work in this case as CancellationListener.cancelled doesn't get triggered right away.
Does that mean this was logged on the server?
That doesn't sound right. It should. Maybe the listener is scheduled to an executor whose threads are busy? Or maybe it's a bug. How reproducible is this?
[warn] i.g.n.NettyServerHandler in grpc-default-worker-ELG-3-3 - Connection Errorjava.io.IOException: Operation timed out at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[na:1.8.0_40] at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[na:1.8.0_40] at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_40] at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[na:1.8.0_40] at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[na:1.8.0_40] at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) ~[netty-buffer-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1054) ~[netty-buffer-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:245) ~[netty-transport-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:106) ~[netty-transport-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:527) [netty-transport-4.1.0.CR7.jar:4.1.0.CR7][error] i.g.n.NettyServerTransport in grpc-default-worker-ELG-3-3 - Transport failedjava.io.IOException: Operation timed out at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[na:1.8.0_40] at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[na:1.8.0_40] at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_40] at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[na:1.8.0_40] at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[na:1.8.0_40] at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) ~[netty-buffer-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1054) ~[netty-buffer-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:245) ~[netty-transport-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:106) ~[netty-transport-4.1.0.CR7.jar:4.1.0.CR7] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:527) [netty-transport-4.1.0.CR7.jar:4.1.0.CR7]