consul health check: 503 Service Unavailable - spring

I'm using spring cloud consul in my application. when I started the application I have no exception (service Registed in consul). but when consul check health I got this error:
HTTP GET https://xxxxxxxxxx:8181/health: 503 Service Unavailable Output: {
"status" : "DOWN"
}
Here is my configuration file:
spring:
application:
name: #pom.artifactId#
cloud:
config:
enabled: false
consul:
config:
enabled: true
host: localhost
port: 8500
discovery:
scheme: https
endpoints:
health:
sensitive: false
restart:
enabled: true
shutdown:
enabled: true
my pom is as follow:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
<version>1.0.0.M6</version>
</dependency>

It looks like your configuration is a little bit incorrect.
The latest documentation contains the following configuration example:
spring:
cloud:
consul:
host: localhost
port: 8500
BTW: The latest spring-cloud-consul version is RC1

Related

springboot cloud Gateway routes to http

I successfully configured HTTPS for my springboot cloud gateway.
But routing is not working after changing to https. Its working fine with http.
my microservices clients are running in http.
This is my config file application.yml
server:
port: 8443
ssl:
enabled: true
key-store: classpath:atest.p12
key-store-password: XXXXXXXXXXXX
key-store-type: PKCS12
eureka:
client:
register-with-eureka: true
serviceUrl:
defaultZone : http://localhost:8761/eureka
spring:
application:
name: gateway_service
cloud:
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
routes:
- id: test_unique
uri: http://localhost:8081/test/v1/unique/
predicates:
- Path=/test/v1/unique/
Could you please help me to invoke microservice client (http) - uri: http://localhost:8081/test/v1/unique/

Deploy spring boot microservices to heroku

I am trying to deploy my microservices to heroku but without success. At first I created application for service registry (eureka) with following configuration:
spring:
application:
name: eureka
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
Next I deploy application, url of deployed app is like https://eureka.herokuapp.com. I configure with this url my other apps like gateway and business services.
Example of my gateway configuration
spring:
application:
name: gateway
server:
port: 8081
eureka:
client:
healthcheck:
enabled: true
serviceUrl:
defaultZone: https://eureka.herokuapp.com/eureka/
same configuration I used for my user service, just different app name (user-service). When I go to https://gateway.herokuapp.com/user-service/user I cannot receive any response. In heroku logs of gateway app I can see exception because of timeout of user service which I don't understand because when I call https://user.herokuapp.com/user directly I get response
I also find out in my eureka dashboard is not registered replicas, I am not sure if it ok. Can you tell me what I did wrong? Thank you.
error log from gateway app:
2019-12-01T19:53:29.503419+00:00 heroku[router]: at=info method=GET
path="/user-service/user" host=gateway.herokuapp.com
request_id=7818f5eb-34af-47f9-94db-7dc4f9609c31 fwd="86.49.253.78"
dyno=web.1 connect=0ms service=8110ms status=500 bytes=465
protocol=https
Your gateway configuration missing gateway discovery section. Also registry does not require "serviceUrl"
Try bellow configuration
registry
spring:
application:
name: eureka
server:
port: 8761
eureka:
instance:
prefer-ip-address: false
client:
register-with-eureka: false
fetch-registry: false
Gateway
spring:
application:
name: gateway
cloud:
discovery:
enabled: true
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
server:
port: 8081
eureka:
client:
fetch-registry: true
register-with-eureka: true
healthcheck:
enabled: true
serviceUrl:
defaultZone: https://eureka.herokuapp.com/eureka/

Spring-Cloud on Weblogic 12.1.2

We have developed Spring-boot microservices with NetFlix OSS/Spring-cloud. In the development environment, we are running with embedded tomcat, it works well.
Now I'm trying to deploy on Weblogic 12.1.2, I'm able to deploy service registry and API-Gateway inside two different managed servers. But When I open Eureka server page, API-Gateway is not registered with the Service Registry.
Service-Registry application.yml
spring:
application:
name: service-registry
server:
port: 61001
eureka:
client:
register-with-eureka: false
fetch-registry: false
api-gateway application.yml
spring:
application:
name: api-gateway
cloud:
loadbalancer:
retry:
enabled: true
# Ribbon - Client side load balancer
ribbon:
ReadTimeout : 60000
ConnectTimeout: 60000
server:
port: 61002
context-path: /nasw
eureka:
client:
serviceUrl:
defaultZone: http://<ipAdr>:61001/eureka/
# instance:
# instanceId:
### Zuul - Router/Filter/Reverse Proxy
zuul:
ignoredServices: '*'
host:
connect-timeout-millis: 100000
socket-timeout-millis: 600000
routes:
network-planning: "**/network-planning/**"
network-schemagen: "**/network-schemagen/**"
network-verification: "**/network-verification/**"
nw-netgeoview-nw-tracer: "**/nw-netgeoview-nw-tracer/**"
### Hystrix - Circuit Breaker/Fault&Latency Tolerant
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 600000
timeout:
enabled: false
isolation:
strategy: SEMAPHORE
Service registry home page
Could you please help me with following queries?
Is it possible to deploy Spring-Cloud on Weblogic 12.1.2?
Is it a correct way to deploy each microservice in a separate managed server?
If Yes, Am I missing any configuration so that api-gateway can register with service-registry?

ZuulException: forward error with Zuul-Eureka

I'm facing a ZuulException: forward error when routing with Zuul and Eureka.
The error not occur during the first minutes but after 1 or 2 mn I get this weird error.
I'm using spring boot 1.4 and spring cloud Camden
If you want to reproduce the error or see my project: https://github.com/Seb69/Spring-demo-ZuulException/tree/master
Eureka config:
server:
port: 9999
spring:
application:
name: eureka-server
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
Service-Gateway config (Zuul):
server:
port: 1111
spring:
application:
name: service-gateway
# ZUUL (Load balancing)
zuul:
ignoredServices: '*'
routes:
service-server:
stripPrefix: true
path: /api/**
serviceId: SERVICE-SERVER
# EUREKA (Service registry)
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://localhost:9999/eureka/
Service config:
server:
port: 8095
spring:
application:
name: service-server
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://localhost:9999/eureka/
Here is a short version of my stack trace:
com.netflix.zuul.exception.ZuulException: Forwarding error
Caused by: com.netflix.client.ClientException: Number of retries on
next server exceeded max 1 retries, while making a call for:
mbp-de-andre:8095
Caused by: java.net.UnknownHostException: mbp-de-andre
FIX:
So, I finaly succeed to make it work !
My problem came from my Macbook Hostname,
Last hostname was: mbp-de-andre
I modify it and I set: `MacBook-Pro-de-ANDRE.local``
Just want to say another fix might be missing dependency:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>

Zuul -> Eureka Server, Basic Authentication issue

I am able to hit the service, if the flow doesn't contain Basic Authorization.
If i use Basic Authorization, it throws "message": "Full authentication is required to access this resource"
Below are my observations:
In ZuulFilter, run() method, i get value for
request.getHeader("Authorization") --> Basic c29tOnNvbzz==
but once it reaches the Micro Service, i am getting value as 'null',
request.getHeader("Authorization") --> null
Using Spring Boot version : 1.4.0.RELEASE
This is my flow:
------------------
Zuul -> Service Discovery (Eureka Server) -> Service
Kindly help, not sure where the Authorization header is vanishing.
Eureka Server yml file:
-------------------------
server.port:4001
eureka.instance.hostname=localhost
eureka.client.fetch-registry:false
eureka.client.register-with-eureka:false
eureka.client.serviceUrl.defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
eureka.client.healthcheck.enabled=true
Zuul yml file:
-----------------
server:
port: 8765
info:
component: Edge Server
eureka:
instance:
leaseRenewalIntervalInSeconds: 3
metadataMap:
instanceId: ${spring.application.name}:${random.value}
client:
# Default values comes from org.springframework.cloud.netflix.eurek.EurekaClientConfigBean
registryFetchIntervalSeconds: 5
instanceInfoReplicationIntervalSeconds: 5
initialInstanceInfoReplicationIntervalSeconds: 5
endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
zuul.sensitive-headers: Cookie,Set-Cookie,Authorization
logging:
level:
ROOT: WARN
se.callista: INFO
# Get info regarding connection to the cofig server and retries if required
org.springframework.cloud.config.client.ConfigServicePropertySourceLocator: INFO
org.springframework.retry.support.RetryTemplate: DEBUG
# Set INFO to see the allocated port
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer: INFO
---
eureka:
instance:
preferIpAddress: true
client:
serviceUrl:
defaultZone: http://localhost:4001/eureka,http://localhost:4002/eureka
Authorization is by default a sensitive header, this means Zuul will not forward them. If you leave it out of the sensitive headers, Zuul will forward the header.
zuul.sensitiveHeaders: Cookie,Set-Cookie
It should also be camelCase instead of hyphenated.
Extra info: https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#cookies-and-sensitive-headers
This solved my problem, but is this the only solution we have ?
ctx.addZuulRequestHeader("Authorization",request.getHeader("‌​Authorization"))
Your property for zuul.sensitiveHeaders is wrong. It is camel case not hyphenated.
https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#cookies-and-sensitive-headers

Resources