I have a local eureka server and one client
Eureka:
server:
port: 1111
eureka:
instance:
prefer-ip-address: true
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://127.0.0.1:1111/eureka/
server:
waitTimeInMsWhenSyncEmpty: 0
Client:
eureka:
instance:
prefer-ip-address: true
client:
serviceUrl:
defaultZone: http://127.0.0.1:1111/eureka/
I have 2 problems:
1) Eureka server throws in log:
NullPointerException:
at com.netflix.eureka.resources.StatusResource.isReplicaAvailable
2) The client connecting with Eureka, but after some time I see in his log next:
RedirectingEurekaHttpClient : Request execution error
javax.ws.rs.WebApplicationException: null at com.netflix.discovery.provider.DiscoveryJerseyProvider.readFrom(DiscoveryJerseyProvider.java:110)
RetryableEurekaHttpClient : Request execution failure
DiscoveryClient : DiscoveryClient_MW/192.168.0.100:client:8080 - was unable to send heartbeat!
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
In log Eureka I see:
InstanceRegistry : DS: Registry: lease doesn't exist, registering resource: CLIENT - 192.168.0.100:client:8080
InstanceResource : Not Found (Renew): CLIENT - 192.168.0.100:client:8080
In Eureka web console the client has a UP status, but also there is a big inscription:
RENEWALS ARE LESSER THAN THE THRESHOLD. THE SELF PRESERVATION MODE IS
TURNED OFF.THIS MAY NOT PROTECT INSTANCE EXPIRY IN CASE OF
NETWORK/OTHER PROBLEM
Although connection is working and I can get link to my client throught Eureka.
Could you explain what it means and how I can get rid from that?
serviceUrl:
defaultZone: http://127.0.0.1:1111/eureka/
in client setting YML, you should add space before "defaultZone" like this:
serviceUrl:
defaultZone: http://127.0.0.1:1111/eureka/
else defaultZone is same level with serviceUrl.
thanks
Related
I have three microservices, all running in Windows 10 localhost.
service-registry properties.yml:
eureka:
client:
fetch-registry: false
register-with-eureka: false
#serviceUrl:
#defaultZone: http://localhost:55003/eureka
server:
maxThreadsForPeerReplication: 0
server:
port: 55003
user-service properties.yml:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:55003/eureka
server:
port: ${random.int(55020,55040)}
spring:
application:
name: user-service
api-gateway properties.yml:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:55003/eureka
server:
port: 55002
spring:
application:
name: api-gateway
cloud:
gateway:
routes:
- uri: lb://user-service
predicates:
- Path=/users/**
This is my config. When I run all three services, I'm getting logs like this, with weird Docker address and also these addresses are in Eureka instances list:
DiscoveryClient_USER-SERVICE/host.docker.internal:user-service:55033 - registration status: 204
When I try to reach the api-gateway at localhost:55002/users/register, I keep getting 500 response with:
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: host.docker.internal/192.168.1.145:55032
I tried to do anything to Windows hosts file, like removing the Docker part, like the other topics advised:
# Added by Docker Desktop
192.168.1.145 host.docker.internal
192.168.1.145 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
In this case, the services are registered with some other weird addresses:
DiscoveryClient_USER-SERVICE/DESKTOP-C48Q87T:user-service:55036 - registration status: 204
And when i try to reach api-gateway, I'm getting another error:
Connection refused: no further information: localhost/127.0.0.1:55032
What seems completely not understandable for me, is that the ports are completely mixed. In first case user-services was registered in 55033 and erro says 55032. In second case. it's 55036 and 55032.
I'm completely confused. What's going on?
I am working with Eureka/Zuul and Springboot microservices.
While mapping multiple instances of same application to Zuul gateway, i am using serviceId attribute.
Here i had shared my application.yml of zuul project.
server:
port: 8093
servlet:
context-path: /apigateway
spring:
application:
name: zuul-proxy
zuul:
sensitiveHeaders: Cookie,Set-Cookie
host:
socketTimeoutMillis: 60000
routes:
authenticator-oauth:
path: /oauth/
url: http://localhost:8092/authenticator/oauth
sample-resource-server:
path: /sample/
serviceId: sample
stripPrefix: false
sample:
ribbon:
NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList
listOfServers: http://localhost:8096,http://localhost:8097
ConnectTimeout: 60000
ReadTimeout: 60000
MaxTotalHttpConnections: 500
MaxConnectionsPerHost: 100
authenticator:
ribbon:
NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList
listOfServers: http://localhost:8092, http://localhost:8091
ConnectTimeout: 1000
ReadTimeout: 5000
MaxTotalHttpConnections: 500
MaxConnectionsPerHost: 100
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8094/eureka/
instance:
preferIpAddress: true
I am able to run my authenticator application.
Also i am able to run my sample application on both port(8096/8097) with load balancing .
Here as you can see i had mapped authenticator service using URL and it's working fine.
url: http://localhost:8092/authenticator/oauth
But when i had mapped it with service id as below code, it's not able to redirect with actual authentication service url.
authenticator-oauth:
path: /authenticator/**
serviceId: authenticator
stripPrefix: false
In both these cases, i am hitting same URL as below
http://localhost:8093/apigateway/oauth/token.
Why authentication service or oauth/token end point behave differently compare to normal application?
Any help will appreciated.
In order to register multiple instance of same micro-service you have to do nothing
in ZUUL API GATEWAY.
Add a property in the micro-service itself for which you are creating multiple instance.
server:
port: ${PORT:0}
eureka:
instance:
instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}
Every time you will start same service it will start on unique port
It will register itself with eureka discovery service
Load Balancing will be done automatically since ribbon comes built in with Zuul
Is there a way via configuration to blacklist specific ip addresses from registering as microservices with Spring Eureka cloud discovery? It seems that each time I restart my discovery service an unrecognized ip instance is registering as a microservice. From the attached image I would expect that only a single instance be present rather than the two shown.
Currently the application.yml file is configured as follows:
---
# This default profile is used when running a single instance completely standalone:
#spring:
# profiles: default
server:
port: 8010
eureka:
instance:
hostname: eurekahost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
security:
basic:
enabled: false
user:
name: user # login username
password: password
Although this is not my ideal solution since I prefer to do this via configuration, I found that I can de-register the service via Eureka's REST API.
I use spring boot 2.0.X and want to use an admin-server that automatically detects other services registered at Eureka. I have followed this guide to the letter, but none of the applications are shown in the admin console. All applications are registered with Eureka successfully.
Admin-server configuration:
server:
port: 8762
spring:
application:
name: admin-server
boot:
admin:
discovery:
ignored-services: admin-server
#The admin server will automatically pick up all services at eureka and register them to itself.
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
health-check-url-path: /actuator/health
metadata-map:
startup: ${random.int} #needed to trigger info and endpoint update after restart
client:
registryFetchIntervalSeconds: 5
registerWithEureka: true #default true
fetchRegistry: true #default true
serviceUrl:
defaultZone: http://localhost:8761/eureka/
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
Eureka server configuration:
server:
port: 8761
spring:
application:
name: discovery-server
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:8761/eureka/
Some thoughts:
We migrated from spring boot 1.5.x to 2.0.x, is there a problem with
security? We don't use spring-security anywhere but I read that some
http endpoints are not "reachable" or "active" by default anymore. But I see no errors or warning in the logf of the admin server or eureka server about this.
None of my other applications have the spring boot admin starter client dependency in their pom, because I don't want THAT to be the part that is responsible for registering ith the admin console, I want it be done dynamically through Eureka
All applications, except the admin server and the eureka server, use
the config-server to fetch their configuration. Does this cause
problems?
The application.yml that all other applications get from the config server contains the following:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
spring:
boot:
admin:
url: http://localhost:8762
management: #exposing all endpoints is not safe for production, especially not if spring security gets involved
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
I had the same issue when upgrading to SBA2.
Versions of spring-boot, spring-cloud and SBA should match. I used:
spring-boot: 2.0.7.RELEASE
spring-cloud: Finchley.SR2
SBA: 2.0.4
In my case the trick was to use spring-boot-admin-starter-server as dependency instead of plain dependencies (spring-boot-admin-server, spring-boot-admin-server-ui, spring-boot-admin-server-cloud) as it is descriped here:
https://github.com/codecentric/spring-boot-admin/issues/776
I've set those parameters in my application.yml:
spring:
servlet:
multipart:
max-file-size: -1
max-request-size: -1
and when I run it from IDE it works fine. The problem starts when I try to run it along with spring cloud, netflix eureka, and zuul proxy. It behaves like there is no such paramteters. It always throws:
"Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.",
Shall I set it somewhere else?
EDIT:
My bootstrap.yml
spring:
profiles: docker
application:
name: test-service
sleuth:
sampler:
probability: 1
zipkin:
base-url: http://zipkin:9411/
cloud:
config:
discovery:
enabled: true
service-id: config-server
fail-fast: true
retry:
initial-interval: 2000
max-interval: 10000
multiplier: 2
max-attempts: 10
eureka:
instance:
hostname: test-service
prefer-ip-address: true
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://eureka-server:8761/eureka/
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
logging:
file: ./logs/log.log
Faced the same issue and found the solution, post it here still anyone needs help after 3years.
If your traffic flow through the Netflix Zuul edge service, you should update the below properties in both Zuul and your file upload application service.
for spring boot 2.x and above its
spring.servlet.multipart.max-file-size=-1
spring.servlet.multipart.max-request-size=-1