eureka client registration failed with nest js - spring-boot

I'm tryng to register to my eureka service discovery with a nestjs project I found on internet a nest js dependency to register with eureka 'nestjs-eureka'. I run a eureka server but I receive a 404 when i run my nest project.
This is my config for :
import {EurekaModule} from "nestjs-eureka";
#Module({
imports: [TypeOrmModule.forRoot(typeOrmConfig),TypeOrmModule.forFeature([ObjectEntity]),
EurekaModule.forRoot({
eureka: {
host: 'localhost:',
port: 8761,
registryFetchInterval: 1000,
servicePath: '',
maxRetries: 3,
},
service: {
name: 'objects',
port: 3000,
},
}),
],
This is my error message:
And this is my eureka server
Thank you advance for your help

Related

Spring Cloud Gateway Circuit Breaker: Default and Specific

I have a Spring Boot application with Spring Cloud Gateway using Resilience4j for circuit breaker:
implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-reactor-resilience4j'
Currently I have the following routes:
routes:
- id: swapi-planets
uri: https://swapi.devs/api/planets/
predicates:
- Path=/api/planets/**
filters:
- name: CircuitBreaker
args:
fallbackUri: https://swapi.dev/api/species/
- id: swapi-species
uri: https://swapi.dev/api/species/
predicates:
- Path=/api/species/**
default-filters:
- name: CircuitBreaker
args:
name: myCircuitBreaker
When I do a call to swapi-planets route I receive the following return from myCircuitBreaker:
{
"timestamp": "2022-07-21T12:48:59.402+00:00",
"path": "/api/planets",
"status": 504,
"error": "Gateway Timeout",
"requestId": "8a8cdca2-1"
}
Is there a way to ignore default circuit breaker filter when the route already have a specific circuit breaker? In this case swapi-planets has a fallbackUri.

How to set the servers property of openapi with Apache Camel?

I am trying to setup a openapi specification and publish the API with Apache Camel and Spring. I tried using restConfiguration, adding the property in the application.yaml, and using the #OpenApiProperty on the app. Everytime the generated yaml reads:
- servers
- url: ""
platform:
# not used
urlrewrite:
enabled: false
token: ${LOCAL_TOKEN:}
apim:
token_ep: ${x/token}
client:
username: ${apim_client_username:}
password: ${apim_client_password:}
consumerKey: ${apim_client_id:}
consumerSecret: ${apim_client_secret:}
endpointsOrchestrated:
server: myServer
emr-endpoint: xxxxxxxx
triggerName: ${PLATFORM_MODULE_ID}
env: dev
domain: ${PLATFORM_MODULE_DOMAIN}
openapi:
title: My Sample api
version: 1.0.0
camel:
dataformat:
jackson:
auto-discover-object-mapper: true
springboot:
tracing: false
rest:
host: myhost.com
port: 8080
spring:
application:
name: aaa
profiles:
active: ${ENV:local}
server:
servlet:
context-path: /
port: ${TOMCAT_PORT:8080}
host: localhost
# MAX HTTP THREADS
tomcat:
threads:
max: ${MAIN_HTTP_THREADS:200}

How to register spring 5 application to eureka client

Thank you for your reply.
i don't know what registers spring(5) application as eureka client.
my application is just read data.
i found that example code before, but i can't apply some code.
and i didn't know what how to execute eureka client code when start my application.
found code
DiscoveryManager.getInstance().initComponent(new MyDataCenterInstanceConfig(), new DefaultEurekaClientConfig());
String vipAddress = "MY-SERVICE";
InstanceInfo nextServerInfo = null;
try {
nextServerInfo = DiscoveryManager.getInstance()
.getEurekaClient()
.getNextServerFromEureka(vipAddress, false);
} catch (Exception e) {
System.err.println("Cannot get an instance of example service to talk to from eureka");
System.exit(-1);
}
System.out.println("Found an instance of example service to talk to from eureka: "
+ nextServerInfo.getVIPAddress() + ":" + nextServerInfo.getPort());
System.out.println("healthCheckUrl: " + nextServerInfo.getHealthCheckUrl());
System.out.println("override: " + nextServerInfo.getOverriddenStatus());
System.out.println("Server Host Name "+ nextServerInfo.getHostName() + " at port " + nextServerInfo.getPort() );
i thought my application executes url "/" in MainController when start.
so, i just that code writes in "/" GetMapping method of MainController.
but i got a error this.
cannot access javax.inject.Provider class file for javax.inject.Provider not found.
how to make code for registers as eureka client and how to use that code...
please help junior! thanks!
Why don't you try use configuration files?
example: application.properties or yml?
Eureka Server:
eureka:
instance:
hostname: localhost
port: 9091
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
waitTimeInMsWhenSyncEmpty: 3000
enableSelfPreservation: false
Microservices Client:
eureka:
instance:
hostname: localhost
port: 9091
client:
registerWithEureka: true
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${eureka.instance.port}/eureka/
server:
wait-time-in-ms-when-sync-empty: 3000

Consul proxy failed to dial: dial tcp 127.0.0.1:0: connect: connection refused

I'm trying to run a consul connect proxy, but it displays unexpected errors
This is my configuration
{
"service": {
"name": "api",
"check": {
"name": "HTTP 80",
"http": "http://localhost:80",
"interval": "10s",
"timeout": "10s"
},
"connect": {
"sidecar_service": {
"proxy":{
"upstreams":[{
"destination_name": "elasticsearch",
"local_bind_port": 9200
}]
}
}
}
}
}
Here is the command with logging
$ consul connect proxy -sidecar-for elasticsearch
==> Consul Connect proxy starting...
Configuration mode: Agent API
Sidecar for ID: elasticsearch
Proxy ID: elasticsearch-sidecar-proxy
==> Log data will now stream in as it occurs:
2019/06/03 08:00:54 [INFO] Proxy loaded config and ready to serve
2019/06/03 08:00:54 [INFO] TLS Identity: spiffe://fadce594-37c1-8586-1b57-c6245436684c.consul/ns/default/dc/dc1/svc/elasticsearch
2019/06/03 08:00:54 [INFO] TLS Roots : [Consul CA 8]
2019/06/03 08:00:54 [INFO] public listener starting on 0.0.0.0:21000
2019/06/03 08:01:02 [ERR] failed to dial: dial tcp 127.0.0.1:0: connect: connection refused
^C==> Consul Connect proxy shutdown
Any suggestions?
The issue is because the service has no port, so it tried to connect to proxy.local_service_port - Defaults to the parent service port.
Specifying the port for the parent service solves the issue

spring cloud config server - No such label: master

My cloud config server was returning the property files but now I am seeing the below error. Please can you let me know how this can be fixed?
This is deployed in pivotal cloud foundry environment.
{
"timestamp": 1464375520539
"status": 404
"error": "Not Found"
"exception": "org.springframework.cloud.config.server.environment.NoSuchLabelException"
"message": "No such label: master"
"path": "/couchbase-data/dev"
}
application.yml
---
spring:
cloud:
config:
server:
git:
uri: https://github.company.com/username/ordering-properties
username: username
password: "{cipher}03f0ac5cc43d913bbd45155f852d1e5c88542878491a1fc89185feea93a40084"
search-paths: couchbase-data
security:
basic:
enabled: true
user:
name: ordering_config
password: "{cipher}dc56acf65f93b5485c87de1a9965e76a2d0b642a0839027deffdbc35f922746f"
manifest.yml
---
name: orderingconfigserver
memory: 2048M
instances: 1
timeout: 180
env:
ENCRYPT_KEY: ORDERING
After I deploy the app , the first hit to the endpoint returns the below error :
{
"timestamp": 1464377154415
"status": 500
"error": "Internal Server Error"
"exception": "java.lang.IllegalStateException"
"message": "Cannot clone or checkout repository"
"path": "/couchbase-data/dev"
}
If your git repo has the main branch name as "main" instead of "master", I would recommend you to add a new property to change default-label as below:
spring.cloud.config.server.git.default-label=main
Check this link for additional info.

Resources