Skip to content

大佬,出现NettyX-Server-Worker-Epoll这个问题是啥原因呀? #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
QianCYang opened this issue Jun 17, 2024 · 12 comments
Closed

Comments

@QianCYang
Copy link

[NettyX-Server-Worker-Epoll-4-4] c.g.n.p.s.DispatcherChannelHandler : handler exception. case=io.netty.channel.unix.Errors$NativeIoException: recvAddress(..) failed: Connection reset by peer, channel=[id: 0xd09192e2, L:/192.123.1.78:5783 - R:/192.168.90.187:56221]

@wangzihaogithub
Copy link
Owner

wangzihaogithub commented Jun 18, 2024

tcp连上后,读内容的过程中,tcp连接被对方close了
有可能是数据没传完,对方就关闭浏览器了。 或者客户端触发超时,直接close tcp连接了

@wangzihaogithub
Copy link
Owner

我下个版本,把这类异常去掉

wangzihaogithub pushed a commit that referenced this issue Jun 18, 2024
tcp连上后,读内容的过程中,tcp连接被对方close了
有可能是数据没传完,对方就关闭浏览器了。 或者客户端触发超时,直接close tcp连接了

#36
@QianCYang
Copy link
Author

java.net.SocketException: Connection reset
	at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:401) ~[na:na]
	at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:434) ~[na:na]
	at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:259) ~[netty-buffer-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132) ~[netty-buffer-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:357) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:553) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.86.Final.jar:4.1.86.Final]
	at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]
	at com.github.netty.core.util.NettyThreadX.run(NettyThreadX.java:50) ~[classes/:na]

我在本地idea 启动了com.github.netty.http.HttpBootstrap 这个测试Springboot项目
然后另一个项目 通过
String forObject = restTemplate.getForObject("http://localhost:8080/test/hello?name=xiaowang", String.class);访问

随着另一个项目的关闭会出现上面的报错,报错率是100%的

@QianCYang
Copy link
Author

java.net.SocketException: Connection reset
at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:401) ~[na:na]
at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:434) ~[na:na]
at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:259) ~[netty-buffer-4.1.86.Final.jar:4.1.86.Final]
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132) ~[netty-buffer-4.1.86.Final.jar:4.1.86.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:357) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:553) ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.86.Final.jar:4.1.86.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.86.Final.jar:4.1.86.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.86.Final.jar:4.1.86.Final]
at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]
at com.github.netty.core.util.NettyThreadX.run(NettyThreadX.java:50) ~[classes/:na]

我在本地idea 启动了com.github.netty.http.HttpBootstrap 这个测试Springboot项目
然后另一个项目 通过
String forObject = restTemplate.getForObject("http://localhost:8080/test/hello?name=xiaowang", String.class);访问

随着另一个项目的关闭会出现上面的报错,报错率是100%的

@wangzihaogithub
Copy link
Owner

你客户端项目的 restTemplate的ClientHttpRequestFactory , 应该用的是长链接的, 然后客户端项目shutdown时候,可能没有来得及执行完ClientHttpRequestFactory.destroy() 或shutdown。

@wangzihaogithub
Copy link
Owner

项目的关闭时,你应该还有正在读数据的请求还没执行完

@wangzihaogithub
Copy link
Owner

这个错误没影响,tomcat也有这个错误,应该log级别比较低,所以平时不会注意。

@QianCYang
Copy link
Author

哦哦哦,好的

@QianCYang
Copy link
Author

image
可以通过啥配置避免出现该问题吗?我这边一出现就是一大堆哦

@QianCYang
Copy link
Author

image 可以通过啥配置避免出现该问题吗?我这边一出现就是一大堆哦

是这样处理吗?
image

@wangzihaogithub
Copy link
Owner

我是这样改的

       if (cause.getClass().getName().startsWith("io.netty.handler.codec.http2")) {
                  // ignore
              } else if (IOException.class.isAssignableFrom(cause.getClass())) {
                  if (logger.isDebugEnabled()) {
                      logger.debug("handler IOException. case={}, channel={}", cause.toString(), context.channel(), cause);
                  }
              } else {
                  logger.warn("handler exception. case={}, channel={}", cause.toString(), context.channel(), cause);
              }

@wangzihaogithub wangzihaogithub mentioned this issue Jun 20, 2024
wangzihaogithub added a commit that referenced this issue Jun 20, 2024
1. 去掉Connection reset by peer的log信息  [#36](#36)
2. netty 和 servlet-api 改为maven强依赖
3. hotfix:对使用beetlsql的项目有影响 : [#37](#37)
@wangzihaogithub
Copy link
Owner

已经在2.3.19解决

#38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants