com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server

后端 未结 10 1655
眼角桃花
眼角桃花 2020-12-30 19:32

I am very new to the microservices and trying to run the code from link: https://dzone.com/articles/advanced-microservices-security-with-spring-and-oa . When I simply run th

10条回答
  •  無奈伤痛
    2020-12-30 20:32

    I was facing the same error when my Eureka client i.e microservice trying to register herself with Eureka Server.

    Client registration eureka service failure registration failed Cannot execute request on any known server

    This error message comes because of following two possibilities.

    1) The defaultZone address is incorrect , either its misspelled or the space is missing after :.

    2) Spring security implemented on Eureka server require a valid CSRF token be sent with every request. Eureka clients will not generally possess a valid cross site request forgery (CSRF) token. So you will need to disable this requirement for the /eureka/** endpoints.

    After disabling the CSRF token with follwoing line of code my Eureka client successfully register them selves with Eureka Server.

    @EnableWebSecurity
    class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.csrf().ignoringAntMatchers("/eureka/**");
            super.configure(http);
        }
    }
    

    Also below is the link from spring docs.

    https://cloud.spring.io/spring-cloud-static/Greenwich.SR2/single/spring-cloud.html#_securing_the_eureka_server

提交回复
热议问题