spring-cloud-gateway: Empty CloseWebSocketFragment leads to sending an invalid CloseStatus 1005
Recently we are seeing the following exception sporadically in our logs. It seems like org.springframework.web.reactive.socket.adapter.ReactorNettyWebSocketSession is not working correctly if the io.netty.handler.codec.http.websocketx.CloseWebSocketFrame is empty:
Stack Trace:
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: WebSocket close status code does NOT comply with RFC-6455: 1005
Caused by: java.lang.IllegalArgumentException: WebSocket close status code does NOT comply with RFC-6455: 1005
at io.netty.handler.codec.http.websocketx.CloseWebSocketFrame.requireValidStatusCode(CloseWebSocketFrame.java:209)
at io.netty.handler.codec.http.websocketx.CloseWebSocketFrame.<init>(CloseWebSocketFrame.java:69)
at reactor.netty.http.client.WebsocketClientOperations.sendClose(WebsocketClientOperations.java:213)
at org.springframework.web.reactive.socket.adapter.ReactorNettyWebSocketSession.close(ReactorNettyWebSocketSession.java:124)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:125)
at reactor.core.publisher.FluxFilter$FilterSubscriber.onNext(FluxFilter.java:113)
at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:220)
at reactor.core.publisher.FluxFirstWithSignal$FirstEmittingSubscriber.onNext(FluxFirstWithSignal.java:330)
at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onNext(ScopePassingSpanSubscriber.java:88)
at reactor.core.publisher.Operators$MonoInnerProducerBase.complete(Operators.java:2634)
at reactor.core.publisher.SinkOneMulticast.tryEmitValue(SinkOneMulticast.java:70)
at reactor.netty.http.server.WebsocketServerOperations.sendCloseNow(WebsocketServerOperations.java:258)
at reactor.netty.http.server.WebsocketServerOperations.onInboundNext(WebsocketServerOperations.java:156)
at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
[...]
I already discussed this in detail in a bug report for Reactor Netty: https://github.com/reactor/reactor-netty/issues/1891
@violetagg was able to convince me that Reactor Netty is doing everything right at this point and that the problem lies in the way org.springframework.cloud.gateway.filter.WebsocketRoutingFilter uses ReactorNettyWebSocketSession
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 16
- Comments: 18 (5 by maintainers)
Commits related to this issue
- fix: WebSocket close status code does NOT comply with RFC-6455: 1005(#1891) https://github.com/reactor/reactor-netty/issues/1891 https://github.com/spring-cloud/spring-cloud-gateway/issues/2451 — committed to mattmok/reactor-netty by deleted user 2 years ago
- fix: WebSocket close status code does NOT comply with RFC-6455: 1005(#1891) https://github.com/reactor/reactor-netty/issues/1891 https://github.com/spring-cloud/spring-cloud-gateway/issues/2451 — committed to mattmok/reactor-netty by deleted user 2 years ago
- fix: WebSocket close status code does NOT comply with RFC-6455: 1005(#1891) https://github.com/reactor/reactor-netty/issues/1891 https://github.com/spring-cloud/spring-cloud-gateway/issues/2451 — committed to mattmok/reactor-netty by deleted user 2 years ago
- Adapt ProxyWebSocketHandler CloseStatus Fixes gh-2451 Fixes gh-2702 — committed to spring-cloud/spring-cloud-gateway by daihuabin 2 years ago
Any news on this one? This error is still polluting our logs.
I’m still facing this issue in 2021.0.3 and too many logs generated in gateway side, i see you moved this bug to 2.21.0.4, hopefully it can be fixed ASAP.
Is there any update on this issue?
any alternative to suppress this error ?
I have tried upgrading to the newest gateway version of spring cloud. The same problem exists, to my knowledge, this is not affecting the behavior of the socket, can anyone confirm that the socket behavior is intact and it is just a log error issue?
Hi, @spencergibb There is too many such error log, which seriously affects our troubleshooting. Is there a temporary solution to avoid this problem, such as bootstrap.yml settings or filter interception filling and StatusCode?
Yes is it possible to have a fix for this ?
We are also experiencing this log message.
So, by @franzvezuli 's comment, can anyone confirm that this is not affecting functionality?