Mongodb EHOSTUNREACH on Openshift Online 3 starter - node.js

I was working on my Openshift app today and without changing anything related to mongodb connection I started getting this message:
/opt/app-root/src/node_modules/mongodb/lib/server.js:242
process.nextTick(function() { throw err; })
^
Error: connect EHOSTUNREACH 172.30.173.215:27017
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
npm info lifecycle bolao_2018#0.1.0~start: Failed to exec start script
npm ERR! Linux 3.10.0-693.21.1.el7.x86_64
npm ERR! argv "/opt/rh/rh-nodejs6/root/usr/bin/node" "/opt/rh/rh-nodejs6/root/usr/bin/npm" "run" "-d" "start"
npm ERR! node v6.11.3
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! bolao_2018#0.1.0 start: `node main`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bolao_2018#0.1.0 start script 'node main'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bolao_2018 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node main
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bolao_2018
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bolao_2018
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /opt/app-root/src/npm-debug.log
The one thing different was that I saw that for some reason the mongodb service tried and failed a new deploy so I ran one manually.
I also noticed that the IP addressit tries to connect is mongodb's cluster IP but the Node IP of the current running pod is different.
Can someone help me figure out what triggered the connection to break?
Thanks

From within a given Project scope, requests directed toward a hostname of "mongodb" should be routed to the Kubernetes Service named "mongodb" (when available).
To debug this connectivity issue:
Try opening a live terminal within your front-end container using the OpenShift web console. The front-end container must be within the same Project scope as the database service
Type env to list environment variables available to the front-end. If this container was started after the creation of the "mongodb" service, configuration strings should be visible the environment
Run curl $MONGODB_SERVICE_HOST:$MONGODB_SERVICE_PORT from the live terminal to verify the availability of the mongodb service

Related

Npm install doesn't succeed in Gitlab Continuous Integration

I'm trying to install dependencies for a project that I've hosted on Gitlab, and my Runner never completes the install. It seems to try to get the dependencies, but always times out. Here is my .gitlab-ci.yml file:
image: node:4.6.0
test_job:
script:
- hostname
- npm config list
- npm install
- echo "After install"
only:
- master
The output looks like this:
npm info attempt registry request try #3 at 3:06:54 PM
npm http request GET https://registry.npmjs.org/babel-register
npm info attempt registry request try #3 at 3:06:54 PM
npm http request GET https://registry.npmjs.org/babel-preset-stage-2
npm info retry will retry, error on last attempt: Error: connect ETIMEDOUT 151.101.12.162:443
npm info retry will retry, error on last attempt: Error: connect ETIMEDOUT 151.101.12.162:443
And finally, after 15 minutes of attempting to retrieve packages:
npm ERR! Linux 4.4.19-rancher
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.6.0
npm ERR! npm v2.15.9
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect
npm ERR! network connect ETIMEDOUT 151.101.12.162:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
I don't think this is a proxy issue since this Runner is running in a Docker container hosted by Gitlab, but aside from that, I don't know what the issue is. Why would npm install fail like this so consistently?
My company had a specific mirror that it wanted us to use for npm packages. When I set that, everything worked fine.

MongoError: server sockets closed in Azure Web App

So I've deployed my express/mongodb app via git to my Azure Web App, and when I open the app's link it keeps loading and shows a black page, my routes doesn't work, but the static files load just fine.
So I went to see the log, and I got this.
D:\home\site\wwwroot\node_modules\mongodb\lib\server.js:236
process.nextTick(function() { throw err; })
^
MongoError: server 127.0.0.1:3000 sockets closed
at null.<anonymous> (D:\home\site\wwwroot\node_modules\mongodb-core\lib\topologies\server.js:330:47)
at g (events.js:260:16)
at emitTwo (events.js:87:13)
at emit (events.js:172:7)
at null.<anonymous> (D:\home\site\wwwroot\node_modules\mongodb-core\lib\connection\pool.js:105:12)
at g (events.js:260:16)
at emitTwo (events.js:87:13)
at emit (events.js:172:7)
at Socket.<anonymous> (D:\home\site\wwwroot\node_modules\mongodb-core\lib\connection\connection.js:145:12)
at Socket.g (events.js:260:16)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at TCP._onclose (net.js:469:12)
npm ERR! Windows_NT 6.2.9200
npm ERR! argv "D:\\Program Files (x86)\\nodejs\\4.2.3\\node.exe" "D:\\Program Files (x86)\\npm\\3.5.1\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v4.2.3
npm ERR! npm v3.5.1
npm ERR! code ELIFECYCLE
npm ERR! cinemat_iq#0.9.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cinemat_iq#0.9.0 start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the cinemat_iq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs cinemat_iq
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls cinemat_iq
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\home\site\wwwroot\npm-debug.log
So the issues appears to be in mongodb's connection command, which I currently have it as
mongoose.connect('mongodb://127.0.0.1:3000/myapp');
I've tried changing to localhost instead of 127.0.0.1, and tried a different port, all resulted the same error.
After some googling/stackoverflowing, it appears that there's a 'lock file' in mongodb that I need to remove, then repair/restart the mongodb service.
The problem is that I can't find this file using Azure Console (which is Windows based), and I couldn't run any mongo or mongod command (it is not recognized as an internal or external command).
So what can I do to get my app to work on Azure?
As I know, there are not any databases supplied directly on Azure WebApps. So the issue was caused by no mongodb instance on the address localhost or 127.0.0.1 of your webapp, not the MongoDB connection string incorrect.
You can try to create an instance of MongoDB on Azure, and copy the connection string to change the code mongoose.connect('<the remote connection string>').
As reference, you can refer to the doc Announcing New MongoDB Instances on Microsoft Azure to know MongoDB on Azure and how to get started.
I don`t think there is local mongoDB in Azure App Service environment, try to change to connect to a remote database (e.g host your mongoDB on an Azure Virtual Machine) should fix your issue.
You can follow this post to:
create a mongoDB instance on mongolab(which is supervised by Azure)
setup your nodejs env variable in your Azure web app setting
reference the env variable in your nodejs code to connect to your mongoDB
All in QuickStart section

Error starting NPM .. Ghost Blog .. error npm start

********** Update *********
This had to do with me changing my ports to those of my ipaddress in config.js so I can test on mobile and table. Any idea how I can do this without changing the ports everytime I reboot the computer so that they are always set to my ipaddress for testing?
**********Original Question ****
I am getting a strange error when starting npm to run my ghost blog. It has happened before and I went back to a previous commit on github. It seems like everytime I get it working through a different method and then stop working and close terminal. Then when I restart its another issues?? Maybe github is causing it. Any help would be great. Tried everything I know how to do.
here is the error message:
cconti77#Charless-iMac ~/sites/_repos/elite-university (get-back-on-it●●●)$ npm start
ghost#0.5.0 start /Users/cconti77/Sites/_repos/elite-university
node index
Migrations: Up to date at version 003
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRNOTAVAIL
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1023:19)
at listen (net.js:1064:10)
at net.js:1146:9
at dns.js:72:18
at process._tickCallback (node.js:419:13)
at process._tickFromSpinner (node.js:394:15)
npm ERR! ghost#0.5.0 start: `node index`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the ghost#0.5.0 start script.
npm ERR! This is most likely a problem with the ghost package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index
npm ERR! You can get their info via:
npm ERR! npm owner ls ghost
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "start"
npm ERR! cwd /Users/cconti77/Sites/_repos/elite-university
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/cconti77/Sites/_repos/elite-university/npm-debug.log
npm ERR! not ok code 0
You are already using the Ghost port for something else.
Most probably ghost exited the wrong way, or you are using forever/pm2 and the process hasn't closed properly. try killing any 'forever/pm2' instances, then reboot your machine. Worked for me.
To understand what happens, I suggest you try the following to see which process uses the ghost port, then kill the process. http://www.cyberciti.biz/faq/what-process-has-open-linux-port/
And also, you're a bit off-topic, this should be moved to SuperUser.

Heroku Node Stormpath

UPDATE
I uploaded this to Azure and it worked immediately - I believe the issue had something to do with the .env file but I cannot be sure.
So I followed the guide here:
and am trying to push the app to Heroku. I have all my config vars correct - however, when the application launches on heroku I receive:
/app/node_modules/stormpath/lib/ds/RequestExecutor.js:59
npm ERR! VisualVMail#0.0.1 start: `node ./bin/www`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the VisualVMail#0.0.1 start script.
npm ERR! This is most likely a problem with the VisualVMail package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls VisualVMail
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.8.11-ec2
npm ERR! command "/app/vendor/node/bin/node" "/app/vendor/node/bin/npm" "st
npm ERR! cwd /app
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /app/npm-debug.log
npm ERR! not ok code 0
throw new Error('request.uri field is required.');
Has anyone been able to get Stormpath / nodejs / heroku running, particularly with this sample application?
It looks like you have an issue with the VisualVMail package -- can you try debugging that? It says in the error that request.uri is required.
The error "request.uri field is required" is from the stormpath library. It would be helpful to see the stacktrace, can you look for it in /app/npm-debug.log? It may be in your heroku logs as well.
If, more recently you used the Stormpath automatic add-on - This is an issue with the way Heroku have setup their integrations with Stormpath (or vice-versa). I've sent them a bug report.
In your Heroku Settings > Config Variables; if you have a variable named STORMPATH_URL, remove it and add a new variable called STORMPATH_APPLICATION_HREF with its value as your application's href, e.g. https://api.stormpath.com/v1/applications/<appIDhere>.
Then it should work.
Or in the case of your env file, STORMPATH_APP_HREF should be STORMPATH_APPLICATION_HREF.

npm not installing packages even after proxy is set

I am trying to set up a node js based application in one of our lab servers where connectivity to internet is achieved via a proxy. The box is running Ubuntu 13.10. I have configured the network proxy and I am able to connect to internet through Firefox. For apt-get, I have configured the proxy in /etc/apt/apt.conf. This is also working.
After installing node js, when I try to do npm install -g <package> it's giving me errors. I have configured the proxy for npm too. My .npmrc looks like this: (my proxy does not require userid/password).
registry = http://registry.npmjs.org/
proxy = http://<domain>:8080/
https-proxy = http://<domain>:8080
I have tried various options found in forums, but none seems to work for me. (Like setting strict-ssl to false, using --without-ssl --insecure option etc.)
This is the error I am getting currently:
npm http GET http://registry.npmjs.org/express
npm http GET http://registry.npmjs.org/express
npm http GET http://registry.npmjs.org/express
npm ERR! Error: connect ECONNREFUSED
npm ERR! at errnoException (net.js:904:11)
npm ERR! at Object.afterConnect [as oncomplete] (net.js:895:19)
npm ERR! { [Error: connect ECONNREFUSED]
npm ERR! code: 'ECONNREFUSED',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! syscall: 'connect' }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly. See: 'npm help config'
npm ERR! System Linux 3.11.0-12-generic
npm ERR! command "/home/<user>/apps/node-v0.10.26-linux-x86/bin/node" "/home/<user>/apps/node-v0.10.26-linux-x86/bin/npm" "install" "-g" "express"
npm ERR! cwd /home/<user>
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! syscall connect
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! stack Error: connect ECONNREFUSED
npm ERR! stack at errnoException (net.js:904:11)
npm ERR! stack at Object.afterConnect [as oncomplete] (net.js:895:19)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/<user>/npm-debug.log
npm ERR! not ok code 0
Any idea, what's going wrong here? I'm stuck with this darn thing for the day ;-(
Thanks!
I haven't been able to get a resolution for this issue, but found a work around - I bundled the packages I require on my laptop and then resorted to offline installation on the lab box. Here is how to do that:
Take for example, mongodb node module. I have it installed on my laptop where I do the development. If you open the package.json file for mongodb module, the dependencies are listed with corresponding version numbers. Mine looks like this:
"dependencies": {
"bson": "0.2.5",
"kerberos": "0.0.3"
},
Update the package.json file to include "bundledDependencies". (the position shouldn't really matter, just that it should be at the same level, as a sibling of "dependencies" in the JSON tree). This is what you need to add:
"bundledDependencies": [
"bson",
"kerberos"
],
Now, while you are within your package's directory (where the package.json file is present), run the command npm pack. That will create a tgz file for you. In my case it created mongodb-1.3.23.tgz. Just copy this file to the box where you want to install it and run npm install ./mongodb-1.3.23.tgz. That should get you through. Since all dependencies are now bundled within this .tgz file, npm won't try to connect to internet for installing any of them.
However, I would still like to know what's going wrong with my internet based installation. That's still a mystery!

Resources