Closed sailu-naredla closed 2 years ago
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
@ryanjbaxter thank you for the quick reply . You can find the sample project on below link https://github.com/sailu-naredla/Spring-Cloud-Projects/tree/master/boot-cloud-gateway
You are getting that message because the fallback is a GET and not a POST
Thank you @ryanjbaxter, by changing the fallback to POST is working as expected for POST request only however it is failing for GET request. So I need to have different fallback for GET and POST request !
Correct you do.
I'm using the latest Spring cloud gateway and Circuit breaker with Resilience4J. I was checking the fallback controller for down service where GET endpoint fallback works fine, but for some reason an error appears for POST endpoint and its trowing an error with status code 405 Method Not Allowed.
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost/127.0.0.1:9001 Caused by: java.net.ConnectException: Connection refused: no further information at java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[na:na] at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:660) ~[na:na] at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:875) ~[na:na] at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330) ~[netty-transport-4.1.73.Final.jar:4.1.73.Final] at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334) ~[netty-transport-4.1.73.Final.jar:4.1.73.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:710) ~[netty-transport-4.1.73.Final.jar:4.1.73.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) ~[netty-transport-4.1.73.Final.jar:4.1.73.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) ~[netty-transport-4.1.73.Final.jar:4.1.73.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) ~[netty-transport-4.1.73.Final.jar:4.1.73.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[netty-common-4.1.73.Final.jar:4.1.73.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.73.Final.jar:4.1.73.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.73.Final.jar:4.1.73.Final] at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
2022-02-15 16:02:26.330 DEBUG 10112 --- [ctor-http-nio-4] i.g.r.c.i.CircuitBreakerStateMachine : Event ERROR published: 2022-02-15T16:02:26.330359600+05:30[Asia/Calcutta]: CircuitBreaker 'ADDRESS-SERVICE' recorded an error: 'io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost/127.0.0.1:9001'. Elapsed time: 2069 ms 2022-02-15 16:02:26.331 DEBUG 10112 --- [ctor-http-nio-4] a.w.r.e.AbstractErrorWebExceptionHandler : [cd24bc1] Resolved [MethodNotAllowedException: 405 METHOD_NOT_ALLOWED "Request method 'POST' not supported"] for HTTP POST /addresses/ 2022-02-15 16:02:26.332 DEBUG 10112 --- [ctor-http-nio-4] o.s.http.codec.json.Jackson2JsonEncoder : [cd24bc1] Encoding [{timestamp=Tue Feb 15 16:02:26 IST 2022, path=/addresses/, status=405, error=Method Not Allowed, req (truncated)...] 2022-02-15 16:02:26.334 DEBUG 10112 --- [ctor-http-nio-4] o.s.w.s.adapter.HttpWebHandlerAdapter : [cd24bc1] Completed 405 METHOD_NOT_ALLOWED
spring-boot-starter-parent >> 2.6.3 spring-cloud.version >> 2021.0.0 Java > 11
Resilience4JConfig to set timeoutDuration for TimeLimiterConfig @Bean public Customizer defaultCustomizer() {
return factory -> factory.configureDefault(id -> new Resilience4JConfigBuilder(id)
.circuitBreakerConfig(CircuitBreakerConfig.ofDefaults())
.timeLimiterConfig(TimeLimiterConfig.custom().timeoutDuration(Duration.ofSeconds(12)).build()).build());
}
application.yml config for Circuit breaker
am I missing something in the config part? -