I am using eureka-js-client to register on Eureka, this works fine when deployed locally, however when I deploy on the AWS, the "hostName" value set is replaced with empty value.
Since I set ingressUrl as hostName, how to stop eureka-js-client not to touch the "hostName" ?
eureka-js-client version - "4.2.0"
Eureka version - 1.9.2, (SpringBoot 2.x)
Here's portion of Eureka config looks like:
"instance": {
"app": "<MyApp>",
"hostName": "<MyHostname>", // I dont want this to be overwritten by AWS-meta-data
"ipAddr": "<MyIp>",
"vipAddress": "<MyVip>",
"secureVipAddress": "<address>",
"homePageUrl": "<url>",
"healthCheckUrl": "<url>",
"statusPageUrl": "<url>",
"instanceId": "<InstanceId>"
"port": {
"$": 80,
"#enabled": false
},
"securePort": {
"$": 443,
"#enabled": true
},
"dataCenterInfo": {
"#class": "com.netflix.appinfo.AmazonInfo",
"name": "Amazon"
},
},
"useLocalMetadata": true
}
This is what I end up doing,
"instance": {
"app": "<MyApp>",
"hostName": "<MyHostname>", // I dont want this to be overwritten by AWS-meta-data
"ipAddr": "<MyIp>",
"vipAddress": "<MyVip>",
"secureVipAddress": "<address>",
"homePageUrl": "<url>",
"healthCheckUrl": "<url>",
"statusPageUrl": "<url>",
"instanceId": "<InstanceId>"
"port": {
"$": 80,
"#enabled": false
},
"securePort": {
"$": 443,
"#enabled": true
},
"dataCenterInfo": {
"#class": "com.netflix.appinfo.AmazonInfo",
"name": "Amazon"
},
"eureka": {
"serviceUrls": {
"default": "<eureka_url>"
},
"fetchMetadata" : false, #turn this off, and set your own metadata, you can use AWSmetada.js present in eurek-client-js
"registerWithEureka" : true
}
}
for more details see here: https://www.npmjs.com/package/eureka-js-client#configuring-for-aws-environments
Related
I currently have a set of nodejs modules (containers) that connect to a local mongodb (also a container).
All modules works perfectly but with one of the I have the following problem:
https://i.stack.imgur.com/xuFqw.png
The connection seems to be accepted by mongo but the client doesn't receive the response and keeps waiting until it times out after 30 second (watch timestamps in the log)
The code of the client is the following:
async function connectToMongo() {
try {
const mongoUrl = 'mongodb://mongo:27017/LocalDB'
let result = await MongoClient.connect(mongoUrl, { useUnifiedTopology: true })
logger.info("Connected to Mongo DB")
return result
} catch (err) {
logger.error("Cannot connect to Mongo - " + err)
throw err
}
}
And is exactly the same as the other modules (that works).
Mongo is started without any settings or authentication.
I have tried using the following hostnames:
mongo : name of the container in which mongo is running
host.docker.internal : to address the host since the 27017 port of the container is binded to the host port
I honestly don't know what to try anymore...does anybody have an idea about what could be the problem?
UPDATE: as requested i'm adding info about how i'm starting the containers. Anyway I have omitted this part because they are started as Azure IoT Edge Modules. Anyway here is the infos from the deployment template:
"modules": {
"mongo": {
"settings": {
"image": "mongodb:0.0.1-replset-noauth",
"createOptions": "{\"HostConfig\":
{\"PortBindings\":{\"27017/tcp\":[{\"HostPort\":\"27017\"}]}}}"
},
"type": "docker",
"version": "1.0",
"status": "running",
"restartPolicy": "always"
},
"healthcheck": {
"settings": {
"image": "${MODULES.HealthCheck.debug}",
"createOptions": {
"HostConfig": {
"PortBindings": {
"9229/tcp": [
{
"HostPort": "9233"
}
]
}
}
}
},
"type": "docker",
"version": "1.0",
"env": {
"MONGO_CONTAINER_NAME": {
"value": "mongo"
},
"MONGO_SERVER_PORT": {
"value": "27017"
},
"DB_NAME": {
"value": "LocalDB"
}
},
"status": "running",
"restartPolicy": "always"
}
},
While this is the configuration of another module that perfectly works:
"shovel": {
"settings": {
"image": "${MODULES.Shovel.debug}",
"createOptions": {
"HostConfig": {
"PortBindings": {
"9229/tcp": [
{
"HostPort": "9229"
}
]
}
}
}
},
"type": "docker",
"version": "1.0",
"env": {
"MONGO_CONTAINER_NAME": {
"value": "mongo"
},
"MONGO_SERVER_PORT": {
"value": "27017"
},
"DB_NAME": {
"value": "LocalDB"
}
},
"status": "running",
"restartPolicy": "always"
},
(it's basically the same)
The modules are currently being launched using the IoT Simulator or on an IoT Edge device as Single Device deployments.
I am trying to connect a MongoDB URI to the strapi backend.
I am able to connect with the main URL but when I created a .env.development variable, I am not able to connect to the database.
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "mongoose",
"settings": {
"uri": "${process.env.DATABASE_URI || ''}"
},
"options": {
"ssl": true
}
}
}
}
Ok, new plan.
try that :
npm install --save dotenv
require('dotenv').config()
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "mongoose",
"settings": {
"uri": `${process.env.DATABASE_URI || ''}`
},
"options": {
"ssl": true
}
}
}
}
I am new to programming and strapi. Just want to share i have problem with deploying to heroku with the same problem. I fix it with this:
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "mongoose",
"settings": {
"uri": "${process.env.DATABASE_URI}",
"database": "${process.env.DATABASE_NAME}"
},
"options": {
"ssl": true
}
}
}
}
If you are deploying to heroku please check the environment variables. When I set environment variables using heroku cli it does not save the whole string. I have to copy and paste to the heroku website directly.
I'm trying to deploy strapi on google cloud app engine (standard env) but I keep getting a 500 server error. I googled all over but no guides have been written on how to successfully deploy strapi on AE.
I tried the suggestions on this thread: https://github.com/strapi/strapi/issues/2146
So I have:
the gcp-build script to install dependencies
an entrypoint in app.yaml to start strapi
my database.json and server.json in strapi are updated
But it does not seem to work for me. I keep getting the following error:
I tried googling that error "app/invalid" but I can't seem to find anything about that.
I also gave the flex env a spin but that failed as well (without a proper error).
This is my app.yaml file:
runtime: nodejs10
instance_class: F2
service: admin
entrypoint: node_modules/strapi/bin/strapi.js
env_variables:
DATABASE_HOST: "host"
DATABASE_PORT: 27017
DATABASE_NAME: "db"
DATABASE_USERNAME: "name"
DATABASE_PASSWORD: "pw"
DATABASE_SRV: true
DATABASE_AUTHENTICATION_DATABASE: "admin"
DATABASE_SSL: true
NODE_ENV: "production"
PORT: 1337
This is my package.json (important parts):
...
"scripts": {
"strapi": "node_modules/strapi/bin/strapi.js",
"gcp-build": "node node_modules/strapi/lib/utils/post-install.js && cd admin && npm run setup"
}
...
"engines": {
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
production database.json:
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "strapi-hook-mongoose",
"settings": {
"client": "mongo",
"host": "host",
"port": 27017,
"database": "db",
"username": "name",
"password": "pw",
"srv": true
},
"options": {
"authenticationDatabase": "admin",
"ssl": true
}
}
}
}
And finally this is my server.json file:
{
"host": "https://admin-dot-ootje-website.appspot.com",
"port": 1337,
"production": true,
"proxy": {
"enabled": false
},
"autoReload": {
"enabled": false
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": false
}
}
I would expect that this works from the getting started guides in AE but it would seem I'm missing something. Does someone know what that error means? Did someone manage to already deploy strapi on AE?
If I get it working I'd like to add it to strapi docs or medium post for other people to find it easier than I did :)
Thanks in advance!
I think your problem provide from server.json file.
This configuration works on my side :
{
"host": "localhost",
"port": "${process.env.PORT || 1337}",
"production": true,
"proxy": {
"enabled": false
},
"autoReload": {
"enabled": false
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": false
}
}
I'm working on a new configuration file in order to have the auth provider working... and some other features. But this first version is working for me.
I keep you update of my search if you need.
## Update 1 ##
I found the good configuration for GCP in production mode.
I share it if anyone else need it :
{
"host": "localhost",
"port": "${process.env.PORT || 1337}",
"production": true,
"proxy": {
"enabled": true,
"ssl": true,
"host": "[project-name].appspot.com",
"port": 443
},
"autoReload": {
"enabled": false
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": false
}
}
I use flexible environment on GCP, but this will work in standard mode I think.
Thanks,
I try to do login to my application using local users kept in mongodb. My application works on Node.js using feathersjs. After run the app I receive an error like below:
Error: You must provide a 'header' in your authentication configuration or pass one explicitly
This is my config file:
{
"host": "localhost",
"port": 3030,
"public": "../public/",
"paginate": {
"default": 10,
"max": 50
},
"authentication": {
"secret": "My secret key",
"strategies": [
"jwt",
"local"
],
"path": "/authentication",
"service": "authentication",
"jwt": {
"header": {
"type": "access"
},
"audience": "https://yourdomain.com",
"subject": "anonymous",
"issuer": "feathers",
"algorithm": "HS256",
"expiresIn": "1d"
},
"local": {
"entity": "user",
"usernameField": "email",
"passwordField": "password"
}
},
"mongodb": "mongodb://localhost:27017/mydb"
}
What is wrong with this?
This was a bug in a recent version of feathers-cli which has been fixed in v2.3.7 so make sure feathers --version show that version. In an existing application you can fix the error message with by changing src/app.js from
app.configure(jwt(config.jwt));
app.configure(local(config.local));
To
app.configure(jwt());
app.configure(local());
Since I switched from the sandbox mode to the real deal I get a client authentication failed error.
Config:
{
"port": 5000,
"api": {
"host": "api.paypal.com/v1/",
"port": "",
"client_id": "-",
"client_secret": "-"
}
}
I've double checked my client id and secret, they are enabled and aren't for the sandbox mode.
Code:
paypalService.getPaypalMethodOption(req.body.paymentMethodOptionId).then(function (paymentMethodOption) {
var invoiceId = uuid.v4();
var payment = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"currency": 'USD',
"total": paymentMethodOption.Price
},
"description": paymentMethodOption.Description,
"invoice_number": invoiceId
}]
};
payment.payer.payment_method = 'paypal';
payment.redirect_urls = {
"return_url": "http://localhost:3000/paypal/execute",
"cancel_url": "http://localhost:3000/donate/cancelled"
};
paypal.payment.create(payment, function (error, payment) {
// error
});
});
What can be the problem?
After searching for a few hours i found out that i needed another property.
Apparently you need to add the property mode with the value "live". The documentation isn't very clear on this part, neither are there any live example codes in the node sdk github repository.
My config now looks like the following:
{
"port": 5000,
"api": {
"mode": "live",
"host": "api.paypal.com",
"port": "",
"client_id": "-",
"client_secret": "-"
}
}