vue-storefront-api
vue-storefront-api copied to clipboard
app ignores config, queries localhost
Just tried to run the app with docker: docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml exec app yarn mage2vs import
Elasticsearch ERROR: 2018-12-24T12:13:06Z
Error: Request error, retrying
POST http://localhost:9200/vue_storefront_catalog_eur/category/2/_update => connect ECONNREFUSED 127.0.0.1:9200
at Log.error (/var/www/node_modules/elasticsearch/src/lib/log.js:226:56)
at checkRespForFailure (/var/www/node_modules/elasticsearch/src/lib/transport.js:259:18)
at HttpConnector.<anonymous> (/var/www/node_modules/elasticsearch/src/lib/connectors/http.js:163:7)
at ClientRequest.wrapper (/var/www/node_modules/lodash/lodash.js:4935:19)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketErrorListener (_http_client.js:401:9)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:66:8)
However, localhost is not what I have given in my config before I started the app. There's http://172.24.0.8:9200
in there and I can confirm there's correct ES on that IP with
docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml exec app curl http://172.24.0.8:9200
.
I would expect the app to query what was given in config, but that's not the case. Why?
@pszreder can You step in on here please?
@janmyszkier I see that you have a problem with non-default index (vue_storefront_catalog_eur). You have to remember that in this case each storeview has a separate elasticsearch configuration (including the host / port), it does not inherit from the "main".
Could you show us the content of your local.json file? At least, "elasticsearch" and "storeViews" root properties.
@pszreder elasticsearch:
"elasticsearch": {
"host": "172.24.0.8",
"port": 9200,
"user": "elastic",
"password": "changeme",
"min_score": 0.01,
"indices": [
"vue_storefront_catalog_eur",
"vue_storefront_catalog_usd",
"vue_storefront_catalog_gbp",
"vue_storefront_catalog"
],
"indexTypes": [
"product",
"category",
"cms",
"attribute",
"taxrule",
"review"
]
},
storeviews:
"storeViews": {
"multistore": true,
"mapStoreUrlsFor": [
"eur",
"gbp",
"usd"
],
"eur": {
"storeCode": "eur",
"disabled": false,
"storeId": 2,
"name": "MyStore Europe",
"url": "/eur/",
"elasticsearch": {
"host": "localhost:8080/api/catalog",
"index": "vue_storefront_catalog_eur"
},
"tax": {
"defaultCountry": "DE",
"defaultRegion": "",
"calculateServerSide": true,
"sourcePriceIncludesTax": true
},
"i18n": {
"fullCountryName": "Europe",
"fullLanguageName": "English",
"defaultLanguage": "EN",
"defaultCountry": "DE",
"defaultLocale": "en-US",
"currencyCode": "EUR",
"currencySign": "€ ",
"dateFormat": "HH:mm D-M-YYYY"
}
},
"usd": {
"storeCode": "usd",
"disabled": false,
"storeId": 3,
"name": "MyStore USA",
"url": "/usd/",
"elasticsearch": {
"host": "localhost:8080/api/catalog",
"index": "vue_storefront_catalog_usd"
},
"tax": {
"defaultCountry": "USA",
"defaultRegion": "",
"calculateServerSide": true,
"sourcePriceIncludesTax": true
},
"i18n": {
"fullCountryName": "United States of America",
"fullLanguageName": "English",
"defaultCountry": "USA",
"defaultLanguage": "en-US",
"defaultLocale": "en-US",
"currencyCode": "USD",
"currencySign": "$ ",
"dateFormat": "HH:mm D-M-YYYY"
}
},
"gbp": {
"storeCode": "gbp",
"disabled": false,
"storeId": 4,
"name": "MyStore UK",
"url": "/gbp/",
"elasticsearch": {
"host": "localhost:8080/api/catalog",
"index": "vue_storefront_catalog_gbp"
},
"tax": {
"defaultCountry": "UK",
"defaultRegion": "",
"calculateServerSide": true,
"sourcePriceIncludesTax": true
},
"i18n": {
"fullCountryName": "United Kingdom",
"fullLanguageName": "English",
"defaultCountry": "UK",
"defaultLanguage": "en-US",
"defaultLocale": "en-US",
"currencyCode": "GBP",
"currencySign": "£ ",
"dateFormat": "HH:mm D-M-YYYY"
}
}
},
Please note, however, the problem is not that elasticsearch is trying to write to incorrect index. Problem is the app queries wrong HOST.
Ok, so it's clearly defined in your configuration file:
"storeViews": {
"multistore": true,
"mapStoreUrlsFor": [
"eur",
"gbp",
"usd"
],
"eur": {
"storeCode": "eur",
"disabled": false,
"storeId": 2,
"name": "MyStore Europe",
"url": "/eur/",
"elasticsearch": {
"host": "localhost:8080/api/catalog",
"index": "vue_storefront_catalog_eur"
},
When you're using eur storeView, application is trying to reach vue_storefront_catalog_eur
index using localhost:8080
ES instance.
You have to remember that in this case each storeview has a separate elasticsearch configuration (including the host / port), it does not inherit from the "main".
But... In this case, there could be also some problem inside "mage2vs import" action.
There is a possibility that it ignore ES configuration comes from node-config and using hard-coded "localhost" value as an elasticsearch host.
@pkarw wdyt?
@pszreder I don't think you're right. Well.. or you are, but this is still a bug. Even if this is source config
"host": "localhost:8080/api/catalog",
why it's connected to localhost:9200
we see in the error? localhost:9200 was nowhere configured.
ALSO localhost:8080/api is api SOURCE, not a write endpoint, so I don't think localhost:8080 provided in elasticsearch host has anything to do with it.
The config.elasticsearch
in vue-storefront-api SHOULD BE write
endpoint - elasticsearch itself. This config property is used in the npm run db ...
scripts.
The URL is set in this line: https://github.com/DivanteLtd/vue-storefront-api/blob/37d8ee822009629dffac252b907afb47e58ac99e/scripts/mage2vs.js#L35
... and then used by `mage2vuestorefront: https://github.com/DivanteLtd/mage2vuestorefront/blob/91e18075afebb57c367e0e25aad3e2b7c71a03b6/src/config.js#L30
Would be awesome if @janmyszkier could help us to debug this issue, why the right value hasn't been passed to mage2vs?
@janmyszkier is the issue still present in v1.8.3?
@lukeromanowicz steps to reproduce fresh git clone of this repo
- clone vue-storefront-api repo
- spin up external host (DO droplet is fine)
- copy default.json to local.json
- provide your magento2 keys in config/local.json and change the elasticsearch node to
"elasticsearch": {
"host": "IP.OF.DO.DROPLET",
- make sure to edit docker-compose to remove references to es1 (also in depends_on nodes in both docker files) so internal ES never launches (makes the connection error easier to spot)
- to spin up docker without elasticsearch run
docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml up -d
- then run dataimport with
docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml exec app yarn mage2vs import
see how you get:
== CREATING NEW DATABASE ==
Elasticsearch INFO: 2019-04-13T20:35:32Z
Adding connection to http://elasticsearch:9200/
** Hello! I am going to create NEW ES index
Elasticsearch DEBUG: 2019-04-13T20:35:32Z
starting request {
"method": "DELETE",
"path": "/*/_alias/vue_storefront_catalog",
"query": {}
}
Elasticsearch ERROR: 2019-04-13T20:35:32Z
Error: Request error, retrying
DELETE http://elasticsearch:9200/*/_alias/vue_storefront_catalog => getaddrinfo ENOTFOUND elasticsearch elasticsearch:9200
at Log.error (/var/www/node_modules/elasticsearch/src/lib/log.js:226:56)
at checkRespForFailure (/var/www/node_modules/elasticsearch/src/lib/transport.js:259:18)
at HttpConnector.<anonymous> (/var/www/node_modules/elasticsearch/src/lib/connectors/http.js:163:7)
at ClientRequest.wrapper (/var/www/node_modules/lodash/lodash.js:4935:19)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketErrorListener (_http_client.js:401:9)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:66:8)
It tried to query named host elasticsearch
completely ignoring the host
config node.
@lukeromanowicz has this issue been addressed? I am encountering the same thing with my configured version of the api.
@cmcmannus my GUESS it's because of this file:
https://github.com/DivanteLtd/vue-storefront-api/blob/master/docker/vue-storefront-api/default.env
which is used during the docker instance creation and from my experience ENV vars CAN override the local config.
and that seems to be the case, because elasticsearch:9200
is exactly what's in this config file.
Still, if I have provided the config in the config file, that's what should be used.
@janmyszkier that was exactly it. Sorry I forgot to update the thread saying I'd figured it out, but thanks for following up!