spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

reactor.netty.channel.AbortedException: Connection has been closed

Open chengtangzheng2021 opened this issue 1 year ago • 3 comments

gateway app is doing routing for many services, there is a service, only one endpoint of that service occasionally got this error at below. restart gateway this error will be gone. reactor.netty.channel.AbortedException: Connection has been closed at reactor.netty.http.server.HttpServerOperations.onInboundClose(HttpServerOperations.java:699) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:

at reactor.netty.http.server.HttpServerOperations.onInboundClose(HttpServerOperations.java:699)
	at reactor.netty.channel.ChannelOperationsHandler.channelInactive(ChannelOperationsHandler.java:73)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:305)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274)
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelInactive(CombinedChannelDuplexHandler.java:418)
	at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:411)
	at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:376)
	at io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:221)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:303)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:301)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
	at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901)
	at io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:813)
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:413)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Unknown Source)

chengtangzheng2021 avatar Jan 18 '24 03:01 chengtangzheng2021

is this apply to gateway? The Request Body Size Limit policy, which by default is set to 1 MB, is applied to all API gateway proxy requests. If the request exceeds this limit, it will be blocked and an error code will be returned. if request body exceed this limit, could this caused this posted issue?

chengtangzheng2021 avatar Jan 18 '24 14:01 chengtangzheng2021

this stacktrace is saying that the connection between gateway client and gateway is closed?

chengtangzheng2021 avatar Jan 25 '24 19:01 chengtangzheng2021

@chengtangzheng2021 AbortedException: Connection has been closed Typically is caused by a client closing a connection1 (see diagram below):

client -> Spring Cloud Gateway -> target service
       ^                       ^
    connection1           connection2

violetagg avatar Jan 26 '24 06:01 violetagg

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues avatar Mar 18 '24 21:03 spring-cloud-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

spring-cloud-issues avatar Mar 25 '24 21:03 spring-cloud-issues

Is this a BUG? In which version is it resolved?

xiehongtao1981 avatar Apr 20 '24 07:04 xiehongtao1981

Can someone reply? Urgent!!

xiehongtao1981 avatar Apr 20 '24 07:04 xiehongtao1981

2024-04-18 11:34:37.179 [reactor-http-epoll-2] WARN reactor.netty.http.client.HttpClientConnect - [cdedc4fd-1, L:/10.200.18.47:50252 - R:10.200.18.140/10.200.18.140:80] The connection observed an error reactor.netty.channel.AbortedException: Connection has been closed at reactor.netty.http.server.HttpServerOperations.onInboundClose(HttpServerOperations.java:615) at reactor.netty.channel.ChannelOperationsHandler.channelInactive(ChannelOperationsHandler.java:73) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:305) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelInactive(CombinedChannelDuplexHandler.java:418) at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:411) at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:376) at io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:221) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:303) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:301) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901) at io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:813) at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:403) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:833)

xiehongtao1981 avatar Apr 20 '24 07:04 xiehongtao1981

@violetagg Is this a BUG? In which version is it resolved?

xiehongtao1981 avatar Apr 22 '24 09:04 xiehongtao1981

@xiehongtao1981 It's not a bug with the Spring Cloud Gateway. We experienced the same error reactor.netty.channel.AbortedException: Connection has been closed and it was caused by flaky proxy component which was breaking the HTTP flow.

Our HTTP flow is end user -> CDN -> F5 -> Spring Cloud Gateway -> Application and there was F5 logic that was not sending the full HTTP request to the Spring Cloud Gateway causing to wait for timeouts. You can reproduce similar behavior by providing bigger HTTP Content-length header than the actual request body size and aggressive read timeout in your client. I'm able to reproduce it in our system by using curl with 1 second timeout directly against the Spring Cloud Gateway.

Check your Spring Cloud Gateway client.

emilnkrastev avatar Apr 23 '24 19:04 emilnkrastev