Spring-cloud-gateway: spring.cloud.gateway.discovery.locator.enabled not working since 2.0.0.RC1

Created on 2 Jun 2018  路  9Comments  路  Source: spring-cloud/spring-cloud-gateway

The spring.cloud.gateway.discovery.locator.enabled property not working since updated Finchley from M9 to RC2. It just keep response 404 all the time.

Most helpful comment

I found this property work:

spring.cloud.gateway.discovery.locator.lowerCaseServiceId=true

See DiscoveryLocatorProperties.lowerCaseServiceId

All 9 comments

That's not enough information. What is your configuration and how to reproduce the error

Here is demo project.

eureka -> gateway -> hello

And then access http://localhost:8080/hello/

It just work fine in Finchley.M9 version. You can change it in build.gradle or root project.

gateway-demo.tar.gz

I think i found the problem.

ServiceInstance::getServiceId is returning upper case name since Finchley.RC1. Route pattern is created in upper case ( /HELLO/** in my demo project for example ). The org.springframework.web.util.pattern.LiteralPathElement instance using by PathRoutePredicateFactory is case sensitive ( prop caseSensitive is true) .

So it always return 404 because "/HELLO/**"not matching with "/hello/" while caseSensitive==true

Not working for me with 'Finchley.RELEASE' and Spring boot '2.0.3.RELEASE'
My configuration:

build.gradle

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-actuator',
            'org.springframework.boot:spring-boot-starter-webflux',
            'org.springframework.cloud:spring-cloud-starter-consul-discovery',
            'org.springframework.cloud:spring-cloud-starter-gateway',
            'org.springframework.boot:spring-boot-starter-aop',
            'org.springframework.retry:spring-retry'
}

bootstrap.properties

spring.application.name=edge-service
spring.cloud.gateway.discovery.locator.enabled=true
spring.cloud.consul.discovery.health-check-path=/actuator/health
spring.cloud.consul.host=${CONSUL_HOST:localhost}

application.properties

server.port=8080
management.endpoints.web.exposure.include=*

Application.class

@EnableDiscoveryClient
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

GET http://localhost:8080/actuator/gateway/routes returns empty list.

@chinfeng for eureka it has always returned upper case. There is a property to force the route to lowercase, I'll find it later.

Thanks @spencergibb .

But why this problem wasn't there unitl Finchley.RC1 ?

I found this property work:

spring.cloud.gateway.discovery.locator.lowerCaseServiceId=true

See DiscoveryLocatorProperties.lowerCaseServiceId

@longshine Thanks! It works!

But this property doesn't included in documents even Finchley.RELEASE.

Was this page helpful?
0 / 5 - 0 ratings