为什么在使用 Web 客户端调用 msa api 时有时会收到 404 错误?

Why do I sometimes get a 404 error when I call msa api using the webclient?

提问人:2nan 提问时间:11/14/2023 更新时间:11/14/2023 访问量:9

问:

弹性云服务器中有一些springboot容器。 容器正在从其他容器(如 B、C 等)向 Web 客户端调用 api。

显然,其他容器正在工作,但偶尔会在调用 Web 客户端时出现以下错误。

服务器当时正在运行,甚至有日志响应来自其他 API 的请求。

2023-11-14T01:51:44.292015743Z org.springframework.web.reactive.function.client.WebClientResponseException$NotFound: 404 Not Found from GET http://localhost:30440/api/test
2023-11-14T01:51:44.292024957Z  at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:202)
2023-11-14T01:51:44.292026787Z  at org.springframework.web.reactive.function.client.DefaultClientResponse.lambda$createException$1(DefaultClientResponse.java:207)
2023-11-14T01:51:44.292027577Z  at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:106)
2023-11-14T01:51:44.292028705Z  at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
2023-11-14T01:51:44.292362211Z  at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onNext(FluxDefaultIfEmpty.java:101)
2023-11-14T01:51:44.292366728Z  at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539)
2023-11-14T01:51:44.292457989Z  at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)
2023-11-14T01:51:44.292459774Z  at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107)
2023-11-14T01:51:44.294668583Z  at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:299)
2023-11-14T01:51:44.294674773Z  at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337)
2023-11-14T01:51:44.294676666Z  at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
2023-11-14T01:51:44.294678113Z  at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:160)
2023-11-14T01:51:44.294679570Z  at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144)
2023-11-14T01:51:44.294681031Z  at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260)
2023-11-14T01:51:44.294682335Z  at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144)
2023-11-14T01:51:44.294683970Z  at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:400)
2023-11-14T01:51:44.294685188Z  at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:419)
2023-11-14T01:51:44.294687234Z  at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:473)
2023-11-14T01:51:44.294688651Z  at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:703)
2023-11-14T01:51:44.294689770Z  at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93)
2023-11-14T01:51:44.294691070Z  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
2023-11-14T01:51:44.294692194Z  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
2023-11-14T01:51:44.294693408Z  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
2023-11-14T01:51:44.294694820Z  at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
2023-11-14T01:51:44.294695991Z  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
2023-11-14T01:51:44.294697894Z  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
2023-11-14T01:51:44.294699430Z  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
2023-11-14T01:51:44.294700728Z  at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
2023-11-14T01:51:44.294701977Z  at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327)
2023-11-14T01:51:44.294702985Z  at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299)
2023-11-14T01:51:44.294705841Z  at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
2023-11-14T01:51:44.294706960Z  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
2023-11-14T01:51:44.294708135Z  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
2023-11-14T01:51:44.294709131Z  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
2023-11-14T01:51:44.294710383Z  at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
2023-11-14T01:51:44.294711755Z  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
2023-11-14T01:51:44.294713163Z  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
2023-11-14T01:51:44.294714287Z  at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
2023-11-14T01:51:44.294715772Z  at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:800)
2023-11-14T01:51:44.294717040Z  at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:487)
2023-11-14T01:51:44.294718575Z  at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:385)
2023-11-14T01:51:44.294722099Z  at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
2023-11-14T01:51:44.294723954Z  at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
2023-11-14T01:51:44.294725738Z  at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
2023-11-14T01:51:44.294727421Z  at java.base/java.lang.Thread.run(Unknown Source)
2023-11-14T01:51:44.294728672Z  Suppressed: java.lang.Exception: #block terminated with an error
2023-11-14T01:51:44.294730471Z      at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
2023-11-14T01:51:44.294731903Z      at reactor.core.publisher.Mono.block(Mono.java:1707)
2023-11-14T01:51:44.294733326Z      at gopos.msa.service.GoposPosService.getTouchkey(GoposPosService.java:354)
2023-11-14T01:51:44.294735069Z      at gopos.master.MasterController.getTouchkey(MasterController.java:501)
2023-11-14T01:51:44.294736666Z      at gopos.master.MasterController$$FastClassBySpringCGLIB$$50bfea48.invoke(<generated>)
2023-11-14T01:51:44.294737978Z      at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
2023-11-14T01:51:44.294740150Z      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
2023-11-14T01:51:44.294741642Z      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
2023-11-14T01:51:44.294743418Z      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
2023-11-14T01:51:44.294745058Z      at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:57)
2023-11-14T01:51:44.294746448Z      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
2023-11-14T01:51:44.294748118Z      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
2023-11-14T01:51:44.294750260Z      at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
2023-11-14T01:51:44.294751662Z      at cmm.aop.RequestAop.loggingRequestInfo(RequestAop.java:83)
2023-11-14T01:51:44.294753323Z      at jdk.internal.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
2023-11-14T01:51:44.294754447Z      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2023-11-14T01:51:44.294755654Z      at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2023-11-14T01:51:44.294757194Z      at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634)
2023-11-14T01:51:44.294758763Z      at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624)
2023-11-14T01:51:44.294760120Z      at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72)
2023-11-14T01:51:44.294761633Z      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
2023-11-14T01:51:44.294763142Z      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
2023-11-14T01:51:44.294764728Z      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
2023-11-14T01:51:44.294766168Z      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
2023-11-14T01:51:44.294767971Z      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
2023-11-14T01:51:44.294769679Z      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
2023-11-14T01:51:44.294771261Z      at gopos.master.MasterController$$EnhancerBySpringCGLIB$$674b05c3.getTouchkey(<generated>)
2023-11-14T01:51:44.294773017Z      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-11-14T01:51:44.294774709Z      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2023-11-14T01:51:44.294776420Z      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2023-11-14T01:51:44.294777911Z      at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2023-11-14T01:51:44.294778941Z      at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
2023-11-14T01:51:44.294780152Z      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
2023-11-14T01:51:44.294781667Z      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
2023-11-14T01:51:44.294783067Z      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
2023-11-14T01:51:44.294784524Z      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
2023-11-14T01:51:44.294785892Z      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
2023-11-14T01:51:44.294787044Z      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1070)
2023-11-14T01:51:44.294788309Z      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
2023-11-14T01:51:44.294789680Z      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
2023-11-14T01:51:44.294790954Z      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
2023-11-14T01:51:44.294792114Z      at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
2023-11-14T01:51:44.294918957Z      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
2023-11-14T01:51:44.294922308Z      at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
2023-11-14T01:51:44.294923246Z      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
2023-11-14T01:51:44.294924149Z      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
2023-11-14T01:51:44.294925239Z      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
2023-11-14T01:51:44.294926114Z      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
2023-11-14T01:51:44.294926744Z      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
2023-11-14T01:51:44.294927670Z      at cmmcloud.filter.SqlInjectionFilter.doFilter(SqlInjectionFilter.java:25)
2023-11-14T01:51:44.294928573Z      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
2023-11-14T01:51:44.294929326Z      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
2023-11-14T01:51:44.294930341Z      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
2023-11-14T01:51:44.294931015Z      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
2023-11-14T01:51:44.294931713Z      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
2023-11-14T01:51:44.295796759Z      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
2023-11-14T01:51:44.295800832Z      at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
2023-11-14T01:51:44.296276211Z      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
2023-11-14T01:51:44.296280307Z      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
2023-11-14T01:51:44.296334691Z      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
2023-11-14T01:51:44.296335735Z      at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96)
2023-11-14T01:51:44.296591053Z      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
2023-11-14T01:51:44.296594278Z      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
2023-11-14T01:51:44.296595461Z      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
2023-11-14T01:51:44.296596452Z      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
2023-11-14T01:51:44.296597176Z      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
2023-11-14T01:51:44.296597973Z      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
2023-11-14T01:51:44.296598999Z      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
2023-11-14T01:51:44.296600422Z      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
2023-11-14T01:51:44.296660572Z      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
2023-11-14T01:51:44.296663422Z      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
2023-11-14T01:51:44.296664360Z      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
2023-11-14T01:51:44.296665646Z      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
2023-11-14T01:51:44.296666557Z      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
2023-11-14T01:51:44.296667487Z      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
2023-11-14T01:51:44.296668851Z      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
2023-11-14T01:51:44.296670293Z      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
2023-11-14T01:51:44.296671118Z      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
2023-11-14T01:51:44.296928968Z      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789)
2023-11-14T01:51:44.296931920Z      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
2023-11-14T01:51:44.296932714Z      at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
2023-11-14T01:51:44.296933290Z      at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
2023-11-14T01:51:44.296933911Z      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
2023-11-14T01:51:44.296935126Z      ... 1 more

问题是什么?

spring-boot spring-web客户端

评论


答: 暂无答案