zio / zio-http

A next-generation Scala framework for building scalable, correct, and efficient HTTP clients and servers
https://zio.dev/zio-http
Apache License 2.0
787 stars 396 forks source link

Emit java.io.IOException: Connection reset by peer #1765

Open changzhiwin opened 1 year ago

changzhiwin commented 1 year ago

Describe the bug The app logic is running ok, but emit Exception, maybe not handle Netty suitable.

ENV OS: macOS Big Sur 11.7.1 zio-http: publishLocal the current master

Additional context [error] 十一月 09, 2022 11:12:05 上午 io.netty.channel.DefaultChannelPipeline onUnhandledInboundException [error] 警告: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. [error] java.io.IOException: Connection reset by peer [error] at sun.nio.ch.FileDispatcherImpl.read0(Native Method) [error] at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) [error] at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) [error] at sun.nio.ch.IOUtil.read(IOUtil.java:192) [error] at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) [error] at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:258) [error] at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132) [error] at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:357) [error] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) [error] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) [error] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) [error] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) [error] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) [error] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) [error] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [error] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [error] at java.lang.Thread.run(Thread.java:748)

vigoo commented 1 year ago

Hi @changzhiwin, do you have a reproducer for this?

oker1 commented 1 year ago

Can't reproduce it but I've encountered the same error when kubernetes probes the app with a low timeout. It's a Connection reset by peer type of error so it should connected with the client closing the connection before receiving the response. I've tried to reproduce it with a sleep and calling with a lower timeout but it does not trigger it. Maybe it has to happen while the response is being sent.