Deploy spring boot microservices to heroku - spring-boot

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/

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/

spring cloud gateway + eureka + microservice on heroku is putting the port in the url result is error 503 on request to microservice via gateway

I have 3 services deployed to Heroku.
Spring cloud Gateway
Eureka
a Microservice
The Gateway and the Microservice are registered in eureka.
GATEWAY application.yml
server:
port: ${PORT:8080}
eureka:
instance:
hostname: gateway.herokuapp.com
homePageUrl: https://${eureka.instance.hostName}/
client:
serviceUrl:
defaultZone: http://eureka.herokuapp.com/eureka/
spring:
application:
name: gateway-service
cloud:
gateway:
routes:
- id: employeeModule
uri: lb://MICROSERVICE
predicates:
- Path=/employee/**
logging:
level:
org.springframework.cloud.gateway: TRACE
EUREKA application.yml
server:
port: ${PORT:8761}
eureka:
instance:
hostname: ${EUREKA_HOSTNAME:localhost}
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: ${EUREKA_URI:http://${eureka.instance.hostname}:${server.port}/eureka/}
MICROSERVICE application.yml
spring:
application:
name: MICROSERVICE
server:
port: ${PORT:8081}
eureka:
instance:
hostname: microservice.herokuapp.com
homePageUrl: https://${eureka.instance.hostName}/
home-page-url-path: https://${eureka.instance.hostName}
client:
serviceUrl:
defaultZone: http://eureka.herokuapp.com/eureka/
I am getting the correct response, when i am calling directly https://MICROSERVICEURL/employee/message
when I am calling the gateway https://GATEWAYURL/employee/message it should ask eureka for the address of the microservice and then route the request to the microservice to get the response.
But instead of routing to https://MICROSERVICEURL/employee/message it routes to the eureka version with the random heroku port. e.g.: https://MICROSERVICEURL:RANDOMHEROKUPORT/employee/message. This leads to an error 503 because of a timeout.
Is there a way to tell the gateway to ignore the port number?
Or am I doing something else wrong?
GATEWAY Log
2020-08-18T19:59:56.683925+00:00 app[web.1]: 2020-08-18 19:59:56.683 TRACE 4 --- [or-http-epoll-1] o.s.c.g.filter.LoadBalancerClientFilter : LoadBalancerClientFilter url chosen: http://microservice.herokuapp.com:41632/employee/message
2020-08-18T20:00:26.673252+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/employee/message" host=gateway.herokuapp.com request_id=236faa79-1d66-4e30-8c32-f879228d08db fwd="79.205.56.29" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 protocol=https
The solution was setting the secure and non secure port for the eureka instance in the appllication.yml
MICROSERVICE application.yml
spring:
application:
name: MICROSERVICE
server:
port: ${PORT:8081}
eureka:
instance:
hostname: microservice.herokuapp.com
homePageUrl: https://${eureka.instance.hostName}/
home-page-url-path: https://${eureka.instance.hostName}
client:
serviceUrl:
defaultZone: http://eureka.herokuapp.com/eureka/
non-secure-port: 80
secure-port: 443
You just need to add the non-secure port and make sure it is enabled in the application.properties or .yml
eureka.instance.non-secure-port-enabled=true
eureka.instance.secure-port-enabled=false
eureka.instance.non-secure-port=80
you could also run it on the secure port but then you can only run 1 service.
My application.properties

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>

consul health check: 503 Service Unavailable

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

Resources