spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components
http://cloud.spring.io/spring-cloud-netflix/
Apache License 2.0
4.87k stars 2.44k forks source link

Load balancer does not have available server for client #1770

Closed mikesockor closed 7 years ago

mikesockor commented 7 years ago

hi guys

GATEWAY
spring:
  application:
    name: gateway-service

aop:
  proxy-target-class: true

server:
  port: 8080

zuul:
  routes:
    crmdata-by-sevice:
      path: /crmdata/**
      serviceId: crmData-service
    crmrecord-by-sevice:
      path: /crmrecord/**
      serviceId: crmRecord-service
    oauth2-by-service:
      path: /uaa/**
      serviceId: oauth2-service

hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 20000

ribbon:
  eureka:
    enabled: true
    ReadTimeout: 20000
    ConnectTimeout: 20000

security:
  oauth2:
    client:
      accessTokenUri: http://localhost:9999/uaa/oauth/token
      userAuthorizationUri: http://localhost:9999/uaa/oauth/authorize
      clientId: upzel
      clientSecret: upzelsecret
    resource:
      userInfoUri: http://localhost:9999/uaa/user

CRMDATA
spring:
  application:
    name: crmData-service

server:
  port: ${vcap.application.port:8060}

eureka:
  client:
    serviceUrl:
      defaultZone: ${vcap.services.eureka-service.credentials.uri:http://127.0.0.1:8761}/eureka
security:
  oauth2:
    resource:
      userInfoUri: http://oauth2-service/uaa/user
---
spring:
  profiles: cloud

eureka:
  instance:
    hostname: ${APPLICATION_DOMAIN}
    nonSecurePort: 80

can somebody help me?

if i using url: http://localhost:8060 all is fine but with serviceId: crmData-service i am getting

com.netflix.zuul.exception.ZuulException: Forwarding error
    at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:158) ~[spring-cloud-netflix-core-1.1.7.RELEASE.jar:1.1.7.RELEASE]
Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: crmData-service

it appeared just after implementing auth server

mikesockor commented 7 years ago

here is formatted issue http://pastebin.com/1B35ZQPV

ryanjbaxter commented 7 years ago

You can format the code in the GitHub issue, see https://help.github.com/articles/creating-and-highlighting-code-blocks/

What is the exact request you are making that is failing?

mikesockor commented 7 years ago

thanks for advice

yeah, localhost:8060/customer working fine, without balancing localhost:8080/crmdata/customer gives to me error in case of serviceId in routes follow config working fine as well

crmdata-by-sevice:
      path: /crmdata/**
     url: http://localhost:8060
spencergibb commented 7 years ago

What does http://<eurekaserver>/eureka/apps say?

mikesockor commented 7 years ago
<?xml version="1.0" encoding="UTF-8"?>
<applications>
   <versions__delta>1</versions__delta>
   <apps__hashcode>UP_2_</apps__hashcode>
   <application>
      <name>CRMRECORD-SERVICE</name>
      <instance>
         <instanceId>192.168.0.79:crmRecord-service:9098</instanceId>
         <hostName>192.168.0.79</hostName>
         <app>CRMRECORD-SERVICE</app>
         <ipAddr>192.168.0.79</ipAddr>
         <status>UP</status>
         <overriddenstatus>UNKNOWN</overriddenstatus>
         <port enabled="true">9098</port>
         <securePort enabled="false">443</securePort>
         <countryId>1</countryId>
         <dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
            <name>MyOwn</name>
         </dataCenterInfo>
         <leaseInfo>
            <renewalIntervalInSecs>30</renewalIntervalInSecs>
            <durationInSecs>90</durationInSecs>
            <registrationTimestamp>1489556230513</registrationTimestamp>
            <lastRenewalTimestamp>1489556230513</lastRenewalTimestamp>
            <evictionTimestamp>0</evictionTimestamp>
            <serviceUpTimestamp>1489556229998</serviceUpTimestamp>
         </leaseInfo>
         <metadata class="java.util.Collections$EmptyMap" />
         <homePageUrl>http://192.168.0.79:9098/</homePageUrl>
         <statusPageUrl>http://192.168.0.79:9098/info</statusPageUrl>
         <healthCheckUrl>http://192.168.0.79:9098/health</healthCheckUrl>
         <vipAddress>crmRecord-service</vipAddress>
         <secureVipAddress>crmRecord-service</secureVipAddress>
         <isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
         <lastUpdatedTimestamp>1489556230513</lastUpdatedTimestamp>
         <lastDirtyTimestamp>1489556229687</lastDirtyTimestamp>
         <actionType>ADDED</actionType>
      </instance>
   </application>
   <application>
      <name>CRMDATA-SERVICE</name>
      <instance>
         <instanceId>192.168.0.79:crmData-service:8060</instanceId>
         <hostName>192.168.0.79</hostName>
         <app>CRMDATA-SERVICE</app>
         <ipAddr>192.168.0.79</ipAddr>
         <status>UP</status>
         <overriddenstatus>UNKNOWN</overriddenstatus>
         <port enabled="true">8060</port>
         <securePort enabled="false">443</securePort>
         <countryId>1</countryId>
         <dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
            <name>MyOwn</name>
         </dataCenterInfo>
         <leaseInfo>
            <renewalIntervalInSecs>30</renewalIntervalInSecs>
            <durationInSecs>90</durationInSecs>
            <registrationTimestamp>1489556224494</registrationTimestamp>
            <lastRenewalTimestamp>1489556224494</lastRenewalTimestamp>
            <evictionTimestamp>0</evictionTimestamp>
            <serviceUpTimestamp>1489556223577</serviceUpTimestamp>
         </leaseInfo>
         <metadata class="java.util.Collections$EmptyMap" />
         <homePageUrl>http://192.168.0.79:8060/</homePageUrl>
         <statusPageUrl>http://192.168.0.79:8060/info</statusPageUrl>
         <healthCheckUrl>http://192.168.0.79:8060/health</healthCheckUrl>
         <vipAddress>crmData-service</vipAddress>
         <secureVipAddress>crmData-service</secureVipAddress>
         <isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
         <lastUpdatedTimestamp>1489556224494</lastUpdatedTimestamp>
         <lastDirtyTimestamp>1489556220783</lastDirtyTimestamp>
         <actionType>ADDED</actionType>
      </instance>
   </application>
</applications>
ryanjbaxter commented 7 years ago

Is your CRMDATA-SERVICE and the Zuul server the same app?

mikesockor commented 7 years ago

now, this is separate modules

spring:
  application:
    name: gateway-service

aop:
  proxy-target-class: true

server:
  port: 8080

zuul:
  routes:
    crmdata-by-sevice:
      path: /crmdata/**
      serviceId: crmData-service
    crmrecord-by-sevice:
      path: /crmrecord/**
      serviceId: crmRecord-service

hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 20000

ribbon:
  eureka:
    enabled: true
    ReadTimeout: 20000
    ConnectTimeout: 20000

as you can see, i removed all security data and this config works fine (by path and serviceId as well) give me please some advice or config example , how can i use zuul as auth server properly

spencergibb commented 7 years ago

how can i use zuul as auth server properly

Please open a separate issue.