I want to complete the spring cloud distributed website construction, but I can not complete Eureka client registration to Euerka Server. I have a question about Spring cloud. When I started three Eureka cluster services, then started a eureka client. Throws the Read timeout exception in one of the Eureka servers.
Here is my Eureka Client's Startup class
#SpringBootApplication
#EnableEurekaClient
public class DeptProvider8001_App {
public static void main(String[] args) {
SpringApplication.run(DeptProvider8001_App.class, args);
}
}
Here is my Eureka Server's Startup class
#SpringBootApplication
#EnableEurekaServer
public class EurekaServer7001_App {
public static void main(String[] args) {
SpringApplication.run(EurekaServer7001_App.class, args);
}
}
These are my eureka Server application.xml
eureka:
#server:
#enable-self-preservation: false
instance:
hostname: eureka7001.com
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone:
http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/
spring:
application:
name: eureka-server
These are my eureka Client application.xml
eureka:
client:
service-url:
defaultZone:
http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/
instance:
instance-id: microservicecloud-dept8001
prefer-ip-address: true
Error Logs
com.sun.jersey.api.client.ClientHandlerException:
java.net.SocketTimeoutException: Read timed out
Related
i'm trying to add Spring Boot Admin to my Eureka Server, but it looks like there is something wrong somewhere.
I'm using
Spring Boot version 2.1.5.RELEASE (starter parent)
spring-cloud-starter-netflix-eureka-server
spring-boot-admin-starter-server
My Main Class is annotated with
#SpringBootApplication
#EnableAdminServer
#EnableEurekaServer
And this is the application.yml
spring:
application:
name: eureka-server
boot:
admin:
context-path: /admin
security:
basic:
enabled: false
management:
security:
enabled: false
eureka:
client:
register-with-eureka: false
fetch-registry: true
instance:
leaseRenewalIntervalInSeconds: 15
After i started the server, i try to launch a microservice
The application.yaml go the client is the following:
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
leaseExpirationDurationInSeconds: 5
client:
service-url:
default-zone: http://localhost:8761/eureka
healthcheck:
enabled: true
lease:
duration: 5
management:
endpoints:
web:
exposure:
include: '*'
security:
enabled: false
but i see it in eureka as down
and i cannot see anything in SBA
I am developing an application with microservice-based arhitecture using Spring Cloud.
I have four applications currently in project:
config-server, eureka-server, gateway-service(zuul) and eureka-client which I am using just to test that the project works as intended.
But I have a problem fetching properties from the config-server.
I have a git repository in which I have one file, eureka-client.yml.
This file has one property message: test message.
I can see that the property is loaded into the config-server if I go to http://localhost:8888/eureka-client/default.
But when I access the property in my eureka-client it returns null.
environment.getProperty("message");
Could someone tell me what am I doing wrong? I'm probably just missing a configuration or .yml property but can't find out which one.
Also the clients are supposed to fetch the properties from the config-server through Eureka.
EDIT:
eureka-server - application.yml
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
register-with-eureka: false
fetch-registry: false
service-url:
default-zone: http://${eureka.instance.hostname}:${server.port}/eureka/
eureka-client - application.yml
server:
port: 8082
And annotated with #EnableDiscoveryClient
config-server - application.yml
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: https://github.com/bpuscasu/config-server
And annotated with #EnableConfigServer and #EnableDiscoveryClient
I am using turbine to aggregate data from hystrix. Everything goes well when I try to get data with hystrix(localhost:23002/hystrix.strean). However,when I try to use turbine to get data, it shows nothing.
Here's my configuration.
server:
port: 23002
spring:
application:
name: hystrix-1
eureka:
client:
serviceUrl:
defaultZone: http://t2.dcfservice.com:23001/eureka/
instance:
hostname: localhost
metadataMap:
cluster : MAIN
spring:
application.name: microservice-hystrix-turbine
server:
port: 23111
security.basic.enabled: false
turbine:
aggregator:
clusterConfig: MAIN
appConfig: hystrix-1
clusterNameExpression: metadata['cluster']
eureka:
client:
serviceUrl:
defaultZone: http://t2.dcfservice.com:23001/eureka/
I can get data with URL:localhost:23002/hystrix.stream
My goal is to get data with URL localhost:23111/turbine.stream?cluster=MAIN
If you posted your yml with exact indentation that is being used in your server, the indentation of below are wrong.
turbine:
aggregator:
clusterConfig: MAIN
appConfig: hystrix-1
clusterNameExpression: metadata['cluster']
appConfig and clusterNameExpression must be a child of turbine, not aggregator
I spent all day trying to make Zuul + Eureka work together, but I hasn't been lucky with that. Zuul alone, without Eureka, works fine. I've tried a lot of different configurations like this one, which says that all I have to do is turn Zull in an Eureka client (by using #EnableDiscoveryClient at root application class).
My setup is very simple: it consists of a service:8080 (service 1), Zuul:9000 and Eureka:8761.
All the approaches I've tried using Eureka gave me the same error when I tried to access service 1 using Zull (http://localhost:9000/service1 in this case):
com.netflix.zuul.exception.ZuulException: Forwarding error
(...)
com.netflix.client.ClientException: Load balancer does not have available server for client: service1
Service 1 is working fine (I can access it directly from the browser address bar http://localhost:8080) and Eureka shows both Zull and Service 1 correctly registered:
The apps are configured like:
Service 1 (bootstrap.yml):
spring:
application:
name: service1
Service 1 (application.yml):
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://127.0.0.1:8761/eureka/
Zuul:
ribbon:
eureka:
enabled: false
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://127.0.0.1:8761/eureka/
healthcheck:
enabled: true
server:
port: 9000
Eureka:
server:
port: 8761
eureka:
client:
register-with-eureka: false
fetch-registry: false
logging:
level:
com:
netflix:
eureka: OFF
discovery: OFF
Zuul Annotations at root application class:
#EnableZuulProxy
#EnableDiscoveryClient
Am I missing any important point?
*****Config Server- Application Service Setup*****
Below is the configuration from application.yml
server:
port: 8882
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
spring:
cloud:
config:
server:
git:uri: https://github.com/appleman/config
Below is the configuration from boostrap.yml
spring:
application:
name: configserver
Starting of this plain spring boot application registers config-server to Eureka.
**General Eureka Server is running on 8761 port
********Below is the Application Client configuration*****
Below is the Application Client configuration in my bootstrap.yml
spring:
application:
name: contractService,envDEV13
cloud:
config:
enabled: true
discovery:
enabled: true
serviceId: configserver
eureka:
instance:
nonSecurePort: ${server.port:8080}
client:
serviceUrl:
defaultZone: http://${eureka.host:localhost}:${eureka.port:8761}/eureka/
Injection of properties in Spring Controller like the below snippet is not working.
#Value("${creditService.eppDbUrl}")
String bar;
Please suggest us if we are doing anything wrong.