Skip to content
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

use custom discoveryclient and get the serviceinstance error #3665

Closed
ranan05 opened this issue Jan 10, 2025 · 2 comments
Closed

use custom discoveryclient and get the serviceinstance error #3665

ranan05 opened this issue Jan 10, 2025 · 2 comments
Labels

Comments

@ranan05
Copy link

ranan05 commented Jan 10, 2025

I defined a discoveryclient, which runs normally in a normal web service and can correctly obtain service information based on the service name. However, in the springcloudgateway service, an error is reported and my custom discoveryclient is not called. Why?

error:
2025-01-10T17:10:00.170+08:00  WARN 70762 --- [ctor-http-nio-2] o.s.c.l.core.RoundRobinLoadBalancer      : No servers available for service: test-service1
2025-01-10T17:10:00.206+08:00 ERROR 70762 --- [ctor-http-nio-2] a.w.r.e.AbstractErrorWebExceptionHandler : [02572793-1]  500 Server Error for HTTP GET "/TestApi"

java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-2
	at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.5.0.jar:3.5.0]
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	*__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
	*__checkpoint ⇢ HTTP GET "/TestApi" [ExceptionHandlingWebHandler]
Original Stack Trace:
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.Mono.block(Mono.java:1710) ~[reactor-core-3.5.0.jar:3.5.0]
		at org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient.choose(BlockingLoadBalancerClient.java:160) ~[spring-cloud-loadbalancer-4.0.0.jar:4.0.0]
		at org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient.lambda$execute$2(RetryableFeignBlockingLoadBalancerClient.java:157) ~[spring-cloud-openfeign-core-4.0.0.jar:4.0.0]
		at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:329) ~[spring-retry-2.0.0.jar:na]
		at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:225) ~[spring-retry-2.0.0.jar:na]
		at org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient.execute(RetryableFeignBlockingLoadBalancerClient.java:135) ~[spring-cloud-openfeign-core-4.0.0.jar:4.0.0]
		at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:102) ~[feign-core-12.1.jar:na]
		at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:72) ~[feign-core-12.1.jar:na]
@spencergibb
Copy link
Member

OpenFeign is blocking and that is not allowed in the WebFlux Gateway Server (or anything WebFlux).

@ranan05
Copy link
Author

ranan05 commented Jan 11, 2025

Indeed, openfeign cannot be used here. I solved this problem because the discoveryclient I defined was wrong and ReactiveDiscoveryClient is required in springcloudgateway. Thank you so much

@spencergibb spencergibb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants