spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.55k stars 3.33k forks source link

Spring Cloud Gateway unable to resolve Eureka DNS #2091

Closed WeiTangLau closed 3 years ago

WeiTangLau commented 3 years ago

Describe the bug I have a microservice architecture application that uses Spring Cloud Gateway as the API Gateway and Eureka Server as Service Discovery. I have tried accessing the path directly at that port and it works. However, I can't seems to route the request to the respective microservice based on the path.

2020-12-28 13:52:07.452 TRACE 24764 --- [ctor-http-nio-6] o.s.c.g.h.p.PathRoutePredicateFactory    : Pattern "/product/v3/api-docs" matches against value "/product/v3/api-docs"
2020-12-28 13:52:07.452 DEBUG 24764 --- [ctor-http-nio-6] o.s.c.g.h.RoutePredicateHandlerMapping   : Route matched: product-service
2020-12-28 13:52:07.453 DEBUG 24764 --- [ctor-http-nio-6] o.s.c.g.h.RoutePredicateHandlerMapping   : Mapping [Exchange: GET http://localhost:8080/product/v3/api-docs] to Route{id='product-service', uri=http://product-service:80, order=0, predicate=Paths: [/api/products/**, /api/products**, /product/v3/api-docs], match trailing slash: true, gatewayFilters=[], metadata={}}
2020-12-28 13:52:07.453 DEBUG 24764 --- [ctor-http-nio-6] o.s.c.g.h.RoutePredicateHandlerMapping   : [5dbe450f-8] Mapped to org.springframework.cloud.gateway.handler.FilteringWebHandler@5d9e5006
2020-12-28 13:52:07.453 DEBUG 24764 --- [ctor-http-nio-6] o.s.c.g.handler.FilteringWebHandler      : Sorted gatewayFilterFactories: [[GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.RemoveCachedBodyFilter@6326c5ec}, order = -2147483648], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter@283d3628}, order = -2147482648], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@7a2a7492}, order = -1], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardPathFilter@59baf2c7}, order = 0], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@138a85d3}, order = 10000], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter@21e484b}, order = 10150], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@ce655b9}, order = 2147483646], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyRoutingFilter@191f4d65}, order = 2147483647], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardRoutingFilter@709d86a2}, order = 2147483647]]
2020-12-28 13:52:07.453 TRACE 24764 --- [ctor-http-nio-6] o.s.c.g.filter.RouteToRequestUrlFilter   : RouteToRequestUrlFilter start
2020-12-28 13:52:07.478 ERROR 24764 --- [ctor-http-nio-4] a.w.r.e.AbstractErrorWebExceptionHandler : [5dbe450f-8]  500 Server Error for HTTP GET "/product/v3/api-docs"

java.net.UnknownHostException: failed to resolve 'product-service' after 2 queries 
    at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.55.Final.jar:4.1.55.Final]
    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 "/product/v3/api-docs" [ExceptionHandlingWebHandler]

Spring Boot Version: 2.4.1, Spring Cloud version: 2020.0.0 Tested on Spring Boot Version 2.3.7, Spring Cloud version hoxton sr9 and it works.

spencergibb commented 3 years ago

Please learn how to properly format code and logs.

Please provide your configuration.

spring-cloud-issues commented 3 years ago

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.

nirajthanki6 commented 3 years ago

@spencergibb : I have received the similar error while in Gateway Configuration below is details for it. Please help us provide your feedback Error Log :

2021-01-18T22:42:10.555190+00:00 heroku[router]: at=info method=POST path="/api/orders/placeorder" host=devopsusa-gateway-service.herokuapp.com request_id=05c7be18-03da-4404-9241-83b71352a3ac fwd="64.255.142.171" dyno=web.1 connect=0ms service=89ms status=500 bytes=284 protocol=https
2021-01-18T22:42:10.550163+00:00 app[web.1]: 2021-01-18 22:42:10.549 ERROR 4 --- [or-http-epoll-1] a.w.r.e.AbstractErrorWebExceptionHandler : [312dedce]  500 Server Error for HTTP POST "/api/orders/placeorder"
2021-01-18T22:42:10.550174+00:00 app[web.1]: 
2021-01-18T22:42:10.550175+00:00 app[web.1]: java.net.UnknownHostException: failed to resolve 'ORDER-SERVICE' after 2 queries 
2021-01-18T22:42:10.550176+00:00 app[web.1]:    at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550177+00:00 app[web.1]:    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
2021-01-18T22:42:10.550178+00:00 app[web.1]: Error has been observed at the following site(s):
2021-01-18T22:42:10.550179+00:00 app[web.1]:    |_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
2021-01-18T22:42:10.550180+00:00 app[web.1]:    |_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
2021-01-18T22:42:10.550181+00:00 app[web.1]:    |_ checkpoint ⇢ HTTP POST "/api/orders/placeorder" [ExceptionHandlingWebHandler]
2021-01-18T22:42:10.550181+00:00 app[web.1]: Stack trace:
2021-01-18T22:42:10.550182+00:00 app[web.1]:        at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550183+00:00 app[web.1]:        at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:966) ~[netty-resolver-dns-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550183+00:00 app[web.1]:        at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:414) ~[netty-resolver-dns-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550184+00:00 app[web.1]:        at io.netty.resolver.dns.DnsResolveContext.onResponse(DnsResolveContext.java:625) ~[netty-resolver-dns-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550184+00:00 app[web.1]:        at io.netty.resolver.dns.DnsResolveContext.access$400(DnsResolveContext.java:63) ~[netty-resolver-dns-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550185+00:00 app[web.1]:        at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:458) ~[netty-resolver-dns-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550185+00:00 app[web.1]:        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) [netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550185+00:00 app[web.1]:        at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571) [netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550186+00:00 app[web.1]:        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550) [netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550186+00:00 app[web.1]:        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) [netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550186+00:00 app[web.1]:        at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616) [netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550187+00:00 app[web.1]:        at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:605) [netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550187+00:00 app[web.1]:        at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104) [netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550188+00:00 app[web.1]:        at io.netty.resolver.dns.DnsQueryContext.trySuccess(DnsQueryContext.java:201) ~[netty-resolver-dns-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550188+00:00 app[web.1]:        at io.netty.resolver.dns.DnsQueryContext.finish(DnsQueryContext.java:193) ~[netty-resolver-dns-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550189+00:00 app[web.1]:        at io.netty.resolver.dns.DnsNameResolver$DnsResponseHandler.channelRead(DnsNameResolver.java:1230) ~[netty-resolver-dns-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550189+00:00 app[web.1]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550190+00:00 app[web.1]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550190+00:00 app[web.1]:        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550190+00:00 app[web.1]:        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[netty-codec-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550191+00:00 app[web.1]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550191+00:00 app[web.1]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550199+00:00 app[web.1]:        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550200+00:00 app[web.1]:        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550200+00:00 app[web.1]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550201+00:00 app[web.1]:        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550201+00:00 app[web.1]:        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550201+00:00 app[web.1]:        at io.netty.channel.epoll.EpollDatagramChannel.read(EpollDatagramChannel.java:681) ~[netty-transport-native-epoll-4.1.54.Final-linux-x86_64.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550202+00:00 app[web.1]:        at io.netty.channel.epoll.EpollDatagramChannel.access$100(EpollDatagramChannel.java:58) ~[netty-transport-native-epoll-4.1.54.Final-linux-x86_64.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550203+00:00 app[web.1]:        at io.netty.channel.epoll.EpollDatagramChannel$EpollDatagramChannelUnsafe.epollInReady(EpollDatagramChannel.java:499) ~[netty-transport-native-epoll-4.1.54.Final-linux-x86_64.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550204+00:00 app[web.1]:        at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe$1.run(AbstractEpollChannel.java:388) ~[netty-transport-native-epoll-4.1.54.Final-linux-x86_64.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550205+00:00 app[web.1]:        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550205+00:00 app[web.1]:        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550205+00:00 app[web.1]:        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384) ~[netty-transport-native-epoll-4.1.54.Final-linux-x86_64.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550206+00:00 app[web.1]:        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550206+00:00 app[web.1]:        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550207+00:00 app[web.1]:        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
2021-01-18T22:42:10.550207+00:00 app[web.1]:        at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_275-heroku]
2021-01-18T22:42:10.550207+00:00 app[web.1]: 
2021-01-18T22:42:39.818064+00:00 app[web.1]: 2021-01-18 22:42:39.817  INFO 4 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2021-01-18T22:47:39.818873+00:00 app[web.1]: 2021-01-18 22:47:39.818  INFO 4 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2021-01-18T22:52:39.819670+00:00 app[web.1]: 2021-01-18 22:52:39.819  INFO 4 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration

Versions : Spring Boot Version: 2.4.0, Spring Cloud version: 2020.0.0-M5 Gateway Config yml :


spring:
  application:
    name: gateway-service
  cloud:
    gateway:
      routes:
        - id: order-service
          uri: lb://ORDER-SERVICE
          predicates:
            - Path=/api/orders/**
        - id: payment-service
          uri: lb://PAYMENT-SERVICE
          predicates:
            - Path=/api/payment/**
server:
  port: 9090

eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    serviceUrl:
      defaultZone: https://springboot-discovery.herokuapp.com/eureka
  instance:
    hostname: ${vcap.application.uris[0]:localhost}
    preferIpAddress: true
    lease-renewal-interval-in-seconds: 10
    lease-expiration-duration-in-seconds: 20

ORDER-SERVICE Config yml :


spring:
  application:
    name: ORDER-SERVICE
  datasource:
    url: jdbc:mysql://devopsusa.com:3306/db_ecommerce
    username: ${DB_USER}
    password: ${DB_PASSWORD}
    jpa:
      hibernate.ddl-auto: update
      generate-ddl: true
      show-sql: true

server:
  port: 8083

eureka:
  instance:
    instanceId: ${spring.application.name}
    hostname: ${spring.application.name}
    preferIpAddress: false
    lease-renewal-interval-in-seconds: 10
    lease-expiration-duration-in-seconds: 20
  client:
    register-with-eureka: true
    fetch-registry: true
    serviceUrl:
      defaultZone: https://springboot-discovery.herokuapp.com/eureka
WeiTangLau commented 3 years ago

@nirajthanki6 @spencergibb yes that is the problem that I have faced. I have similar configuration as well For temporary solution, I reverted back to spring boot version 2.3.x

EGo14T commented 3 years ago

eureka.instance.hostname=localhost add this config to your microservice

spencergibb commented 3 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.

WeiTangLau commented 3 years ago

@spencergibb Sorry I am not able to reproduce the problem now as I have reverted my project back to 2.3.x.

@nirajthanki6 maybe can help on this?

spring-cloud-issues commented 3 years ago

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.

AnasKamali commented 3 years ago

I am tring to build a simple gateway having following DNS related error please help where I am doing wrong ERROR LOG

java.net.UnknownHostException: failed to resolve 'DESKTOP-96SGU3T' after 2 queries at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final] Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): | checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain] | checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain] |_ checkpoint ⇢ HTTP POST "/departments/" [ExceptionHandlingWebHandler] Stack trace: at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final] at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:966) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final] at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:414) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final] at io.netty.resolver.dns.DnsResolveContext.onResponse(DnsResolveContext.java:625) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final] at io.netty.resolver.dns.DnsResolveContext.access$400(DnsResolveContext.java:63) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final] at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:458) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:605) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.resolver.dns.DnsQueryContext.trySuccess(DnsQueryContext.java:201) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final] at io.netty.resolver.dns.DnsQueryContext.finish(DnsQueryContext.java:193) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final] at io.netty.resolver.dns.DnsNameResolver$DnsResponseHandler.channelRead(DnsNameResolver.java:1230) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[netty-codec-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:93) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

application.yml server: port: 9191

spring: application: name: API-GATEWAY cloud: gateway: routes:

eureka: client: fetch-registry: true register-with-eureka: true service-url: defaultZone: http://localhost:8761/eureka instance: hostname: localhost

prefer-ip-address: true

rodmccutcheon commented 3 years ago

Here's a sample that reproduces the problem: https://github.com/rodmccutcheon/spring-cloud-dns-issue

Spring Boot 2.4.2, Spring Cloud 2020.0.1, Mac OS - first part of the error seems to indicate an issue with mac os dns resolution

When the api-gateway attempts to route to the web microservice it gives the following error:

2021-02-12 14:50:57.230  INFO 7504 --- [           main] com.example.demo.ApiGatewayApplication   : Started ApiGatewayApplication in 3.105 seconds (JVM running for 3.904)
Available Services:
api-gateway
web
2021-02-12 14:51:05.548  WARN 7504 --- [ctor-http-nio-2] i.n.r.d.DnsServerAddressStreamProviders  : Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS.

java.lang.reflect.InvocationTargetException: null
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) ~[na:na]
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) ~[na:na]
    at io.netty.resolver.dns.DnsServerAddressStreamProviders.<clinit>(DnsServerAddressStreamProviders.java:64) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.resolver.dns.DnsNameResolverBuilder.<init>(DnsNameResolverBuilder.java:58) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final]
    at reactor.netty.transport.NameResolverProvider.newNameResolverGroup(NameResolverProvider.java:405) ~[reactor-netty-core-1.0.3.jar:1.0.3]
    at reactor.netty.transport.ClientTransportConfig.getOrCreateDefaultResolver(ClientTransportConfig.java:230) ~[reactor-netty-core-1.0.3.jar:1.0.3]
    at reactor.netty.transport.ClientTransportConfig.resolverInternal(ClientTransportConfig.java:216) ~[reactor-netty-core-1.0.3.jar:1.0.3]
    at reactor.netty.http.client.HttpClientConfig.resolverInternal(HttpClientConfig.java:420) ~[reactor-netty-http-1.0.3.jar:1.0.3]
    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:262) ~[reactor-netty-http-1.0.3.jar:1.0.3]
    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect$$Lambda$880/0x0000000038135c20.accept(Unknown Source) ~[na:na]
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:76) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoRetryWhen.subscribeOrReturn(MonoRetryWhen.java:46) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:269) ~[reactor-netty-http-1.0.3.jar:1.0.3]
    at reactor.core.publisher.Flux.subscribe(Flux.java:8147) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:173) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:154) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4046) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:173) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4046) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:173) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:73) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:281) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:860) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:73) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1789) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:281) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:860) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1789) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoFilterWhen$MonoFilterWhenMain.onNext(MonoFilterWhen.java:149) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2359) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoFilterWhen$MonoFilterWhenMain.onSubscribe(MonoFilterWhen.java:112) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4046) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:448) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onNext(FluxConcatMap.java:250) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onNext(FluxDematerialize.java:98) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onNext(FluxDematerialize.java:44) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:270) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:228) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.request(FluxDematerialize.java:127) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:235) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onSubscribe(FluxDematerialize.java:77) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.InternalFluxOperator.subscribe(InternalFluxOperator.java:62) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:54) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4046) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:448) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:218) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4046) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:173) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.4.2.jar:3.4.2]
    at reactor.netty.http.server.HttpServer$HttpServerHandle.onStateChange(HttpServer.java:860) ~[reactor-netty-http-1.0.3.jar:1.0.3]
    at reactor.netty.ReactorNetty$CompositeConnectionObserver.onStateChange(ReactorNetty.java:638) ~[reactor-netty-core-1.0.3.jar:1.0.3]
    at reactor.netty.transport.ServerTransport$ChildObserver.onStateChange(ServerTransport.java:475) ~[reactor-netty-core-1.0.3.jar:1.0.3]
    at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:525) ~[reactor-netty-http-1.0.3.jar:1.0.3]
    at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:94) ~[reactor-netty-core-1.0.3.jar:1.0.3]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:209) ~[reactor-netty-http-1.0.3.jar:1.0.3]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) ~[netty-codec-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) ~[netty-codec-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
    at java.base/java.lang.Thread.run(Thread.java:845) ~[na:na]
Caused by: java.lang.UnsatisfiedLinkError: io/netty/resolver/dns/macos/MacOSDnsServerAddressStreamProvider.resolvers()[Lio/netty/resolver/dns/macos/DnsResolver;
    at io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider.retrieveCurrentMappings(MacOSDnsServerAddressStreamProvider.java:107) ~[netty-resolver-dns-native-macos-4.1.58.Final-osx-x86_64.jar:4.1.58.Final]
    at io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider.<init>(MacOSDnsServerAddressStreamProvider.java:103) ~[netty-resolver-dns-native-macos-4.1.58.Final-osx-x86_64.jar:4.1.58.Final]
    ... 119 common frames omitted

2021-02-12 14:51:10.688 ERROR 7504 --- [ctor-http-nio-4] a.w.r.e.AbstractErrorWebExceptionHandler : [94c574b4-1]  500 Server Error for HTTP GET "/api/v1/test"

java.net.UnknownHostException: failed to resolve '192-168-1-107.tpgi.com.au' after 2 queries 
    at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final]
    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 "/api/v1/test" [ExceptionHandlingWebHandler]
Stack trace:
        at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:966) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:414) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.resolver.dns.DnsResolveContext.access$600(DnsResolveContext.java:63) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:463) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:609) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:117) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.resolver.dns.DnsQueryContext.tryFailure(DnsQueryContext.java:225) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.resolver.dns.DnsQueryContext$4.run(DnsQueryContext.java:177) ~[netty-resolver-dns-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:170) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:164) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.58.Final.jar:4.1.58.Final]
        at java.base/java.lang.Thread.run(Thread.java:845) ~[na:na]
Caused by: io.netty.resolver.dns.DnsNameResolverTimeoutException: [/0.0.0.0:53] query via UDP timed out after 5000 milliseconds (no stack trace available)
spencergibb commented 3 years ago

The original issue was a problem in revolving the service id from service discovery. A dns issue in netty resolving 192-168-1-107.tpgi.com.au is not an issue I can deal with

spring-cloud-issues commented 3 years ago

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.

tomusaleem commented 3 years ago

I'm also facing the same issue while accessing the registered service on eureka naming server through api gateway.

2021-02-19 15:07:42.601 ERROR 8140 --- [ctor-http-nio-4] a.w.r.e.AbstractErrorWebExceptionHandler : [88cde772-2]  500 Server Error for HTTP GET "/CURRENCY-CONVERSION/currency-conversion-feign/from/USD/to/PKR/quantity/10"

java.net.UnknownHostException: failed to resolve 'Confiz-3790.confiz.local' after 2 queries 
    at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.59.Final.jar:4.1.59.Final]
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
    |_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
    |_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
    |_ checkpoint ⇢ HTTP GET "/CURRENCY-CONVERSION/currency-conversion-feign/from/USD/to/PKR/quantity/10" [ExceptionHandlingWebHandler]
Stack trace:
        at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:966) ~[netty-resolver-dns-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:414) ~[netty-resolver-dns-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.resolver.dns.DnsResolveContext.onResponse(DnsResolveContext.java:601) ~[netty-resolver-dns-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.resolver.dns.DnsResolveContext.access$400(DnsResolveContext.java:63) ~[netty-resolver-dns-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:458) ~[netty-resolver-dns-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) ~[netty-common-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571) ~[netty-common-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550) ~[netty-common-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) ~[netty-common-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616) ~[netty-common-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:605) ~[netty-common-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104) ~[netty-common-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.resolver.dns.DnsQueryContext.trySuccess(DnsQueryContext.java:201) ~[netty-resolver-dns-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.resolver.dns.DnsQueryContext.finish(DnsQueryContext.java:193) ~[netty-resolver-dns-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.resolver.dns.DnsNameResolver$DnsResponseHandler.channelRead(DnsNameResolver.java:1230) ~[netty-resolver-dns-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[netty-codec-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:93) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.59.Final.jar:4.1.59.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.59.Final.jar:4.1.59.Final]
        at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
tomusaleem commented 3 years ago

Here is the sample repo: https://github.com/tomusaleem/microservices-sample

Please run the following services to reproduce mentioned error.

Endpoint which is producing mentioned error: http://localhost:8765/currency-conversion/currency-conversion/from/USD/to/PKR/quantity/10

ThiagoAnd commented 3 years ago

Here is the sample repo: https://github.com/tomusaleem/microservices-sample

Please run the following services to reproduce mentioned error.

  • naming server
  • currency-exchange-service
  • currency-conversion-service
  • api-gateway

Endpoint which is producing mentioned error: http://localhost:8765/currency-conversion/currency-conversion/from/USD/to/PKR/quantity/10

Did you manage to resolve it? Are you doing the in28minutes course also? I'm stuck on this part too.

UPDATE:

I manage to work just stopping all the applications, restarting the computer and starting the applications again. My Spring cloud API gateway project's application.properties is this way:

spring.application.name=api-gateway server.port=8765 eureka.client.service-url.defaultZone=http://localhost:8761/eureka spring.cloud.gateway.discovery.locator.enabled=true

tomusaleem commented 3 years ago

@ThiagoAnd No I couldn't resolve it. I'll try it again. Thanks

NikitaStriga commented 3 years ago

hello guys. Was the same problem. In all services and eureka server i add: cloud 2020.0.1 boot 2.4.3 java 11

eureka: instance: prefer-ip-address: true

and double to eureka-server:

eureka: instance: hostname: localhost

summary i have 3 instances:


eureka server yml: server: port: 8761

eureka: instance: prefer-ip-address: true hostname: localhost client: register-with-eureka: false fetch-registry: false

spring: application: name: registry


eureka client yml: server: port: 8181

spring: application: name: customers

eureka: instance: prefer-ip-address: true


and gateway yml: spring: cloud: loadbalancer: ribbon: enabled: false gateway: metrics: enabled: true discovery: locator: enabled: true lower-case-service-id: true application: name: gateway eureka: instance: prefer-ip-address: true

and routing for gateway: @Bean RouteLocator gateway(RouteLocatorBuilder rlb) { return rlb. routes() .route( route -> route.path("/customers") .uri("lb://customers/") ) .build(); }

if i go to localhost:9999/customers l will move to my:customer:service/customers and its works for me. summary what i changed: prefer-ip-adress and hostname. It works for me. I spend about a day to solve it, hope it will help

PPMHackathon commented 3 years ago

hello guys. Was the same problem. In all services and eureka server i add: cloud 2020.0.1 boot 2.4.3 java 11

eureka: instance: prefer-ip-address: true

and double to eureka-server:

eureka: instance: hostname: localhost

summary i have 3 instances:

eureka server yml: server: port: 8761

eureka: instance: prefer-ip-address: true hostname: localhost client: register-with-eureka: false fetch-registry: false

spring: application: name: registry

eureka client yml: server: port: 8181

spring: application: name: customers

eureka: instance: prefer-ip-address: true

and gateway yml: spring: cloud: loadbalancer: ribbon: enabled: false gateway: metrics: enabled: true discovery: locator: enabled: true lower-case-service-id: true application: name: gateway eureka: instance: prefer-ip-address: true

and routing for gateway: @bean RouteLocator gateway(RouteLocatorBuilder rlb) { return rlb. routes() .route( route -> route.path("/customers") .uri("lb://customers/") ) .build(); }

if i go to localhost:9999/customers l will move to my:customer:service/customers and its works for me. summary what i changed: prefer-ip-adress and hostname. It works for me. I spend about a day to solve it, hope it will help

Thanks. I had the same issue, worked for me.

xubmuajkub commented 3 years ago

Thanks @NikitaStriga, your solution is worked.

MikeParkGit commented 3 years ago

eureka.instance.hostname=localhost add this config to your microservice

This works for me

Palgogo commented 2 years ago

adding eureka.instance.prefer-ip-address=true in service without setting hostname in discovery service also works

ravi-prajapati-1995 commented 2 years ago

eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka eureka.instance.hostname=localhost eureka.instance.prefer-ip-address=true eureka.client.fetch-registry=true

I am using above configuration for all the services, but getting the same DNS error

theinsideshine commented 1 year ago

hello guys. Was the same problem. In all services and eureka server i add: cloud 2020.0.1 boot 2.4.3 java 11

eureka: instance: prefer-ip-address: true

and double to eureka-server:

eureka: instance: hostname: localhost

summary i have 3 instances:

eureka server yml: server: port: 8761

eureka: instance: prefer-ip-address: true hostname: localhost client: register-with-eureka: false fetch-registry: false

spring: application: name: registry

eureka client yml: server: port: 8181

spring: application: name: customers

eureka: instance: prefer-ip-address: true

and gateway yml: spring: cloud: loadbalancer: ribbon: enabled: false gateway: metrics: enabled: true discovery: locator: enabled: true lower-case-service-id: true application: name: gateway eureka: instance: prefer-ip-address: true

and routing for gateway: @bean RouteLocator gateway(RouteLocatorBuilder rlb) { return rlb. routes() .route( route -> route.path("/customers") .uri("lb://customers/") ) .build(); }

if i go to localhost:9999/customers l will move to my:customer:service/customers and its works for me. summary what i changed: prefer-ip-adress and hostname. It works for me. I spend about a day to solve it, hope it will help

Thanks it worked for me, your code, I'm using

     <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.0.7</version>

    <java.version>17</java.version>
    <spring-cloud.version>2022.0.3</spring-cloud.version>
Narenderflora commented 1 year ago

Can some please check on this issue as well : https://github.com/Narenderflora/spring-cloud-gateway/issues/1

Vinay9897 commented 12 months ago

eureka.instance.hostname=localhost add this config to your microservice

if this doesn't work add this in all services application properties eureka.instance.prefer-ip-address=true , it means that the service instances prefer to register using their IP addresses rather than their hostnames.

Souravjb66 commented 10 months ago

eureka.instance.hostname=localhost add this config to your microservice

if this doesn't work add this in all services application properties eureka.instance.prefer-ip-address=true , it means that the service instances prefer to register using their IP addresses rather than their hostnames.

thanks its work for me ..........eureka.instance.prefer-ip-address=true .........put this in other microservices like gateway,and other but not in registry

ANOsman commented 8 months ago

Thanks @NikitaStriga. You saved my day

haktanonur commented 8 months ago

@NikitaStriga No words !!! You are the best, thanks bro

dipanshu-global commented 5 months ago

eureka.instance.hostname=localhost add this config to your microservice

if this doesn't work add this in all services application properties eureka.instance.prefer-ip-address=true , it means that the service instances prefer to register using their IP addresses rather than their hostnames.

thanks its work for me ..........eureka.instance.prefer-ip-address=true .........put this in other microservices like gateway,and other but not in registry