Openshift redis cartridge with strange exceptions ETIMEDOUT on socket.io script - node.js

I have a socket.io node script running that acts as a chat server. I had it running on a local server ok, and have since tried moving it over to openshift.
I used the following cartridge to get it working - https://github.com/smarterclayton/openshift-redis-cart/issues
While running the local version of the server, while connecting to the openshift redis, I get strange timeouts exactly 127 seconds after I run the script.
events.js:72
throw er; // Unhandled 'error' event
^
Error: Redis connection to <server> failed - connect ETIMEDOUT
at RedisClient.on_error (/path/node_modules/redis/index.js:196:24)
at Socket.<anonymous> (/path/node_modules/redis/index.js:106:14)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:442:13)
I have seen the events.js:72 one before, but its usually when I try to run a node script with something already running on that port.
Pretty sure the script itself is fine, as when I swap out the redis server for my local one, it will sit there for days and work fine.
So my question: why is my socket.io script killing itself after exactly 127 seconds when redis is hosted on openshift?

Are you using the rhc port-forward command so that you can connect to redis on OpenShift? Otherwise that port is not publicly available.

Related

Cloud9 + sails.js + phpmyadmin

I have problem with creating basic sails.js application on Cloud9 environment and connecting it to MySQL.
Steps I'm making:
Creating Cloud9 project
installing sails: npm -g install sails
creating project: sails new test
lifting: cd testProject/ and sails lift
Here it's working
Adding mySQL support: mysql-ctl start
still working
adding phpMyAdmin support: phpmyadmin-ctl install
And here, my application stops working. I'm getting exception:
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:905:11)
at Server._listen2 (net.js:1043:14)
at listen (net.js:1065:10)
at Server.listen (net.js:1139:5)
at Array.async.auto.start [as 0] (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/hooks/http/start.js:29:35)
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:484:38
at _each (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Object.async.auto (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:455:9)
at Sails.startServer (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/hooks/http/start.js:16:11)
at Sails.emit (events.js:92:17)
at Sails.emitter.emit (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/after.js:50:11)
at afterBootstrap (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/initialize.js:56:11)
at bootstrapDone (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/bootstrap.js:51:14)
at Object.module.exports.bootstrap (/home/ubuntu/workspace/testProject/config/bootstrap.js:16:3)
at Sails.runBootstrap (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/bootstrap.js:44:25)
at Sails.bound [as runBootstrap] (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at Sails.initialize (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/initialize.js:48:9)
at bound (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:607:21
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:246:17
at iterate (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:146:13)
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:157:25
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:248:21
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:612:34
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/load.js:201:13
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:451:17
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:441:17
at _each (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Object.taskComplete (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:440:13)
at processImmediate [as _immediateCallback] (timers.js:354:15)
Additionally I'm getting info about problem with starting my app, and ability to kill the process. Of course killing does not help.
Could youplease help me with that?
So what's happening is that you're starting your sails server, which binds to port 8080, and then you try to install phpmyadmin which tries to start apache (at port 8080 too!) causing it to actually fail since the port is already in use. You will have to stop sails before trying to install / run phpmyadmin since two servers can't listen on the same port.

light streamer nodejs hello world example throwing error

hello every one i am new in nodejs and want to use the light streamer for my site there is a example on git when i tried to deployed it on my local instance throwing the below error any idea will be appreciated thanks in advance...
here is the example i want to deploy
Light streamer nodjs example
E:\wamp\www\nodeJs\lightstream>node helloworld.js
events.js:85
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1000:19)
ECONNREFUSED suggests that the application is not able to connect to the desired TCP port (most likely it is being blocked by a firewall or there is no application listening on that port).
Assuming you have not changed the configuration in helloworld.js:
Have you installed the lightstream server locally and checked it is running? If so, check Windows Firewall and add rules to allow inbound ports 6663 and 6664.

Mongoose Can't Connect Without Internet

I have my MongoDB server running on localhost:27017, and while I can usually run my Node.js app fine, when I disconnect from the internet Mongoose throws the error
Error: failed to connect to [localhost:27017]
Note that I can still connect to the MongoDB server from the Mongo shell client. Also, if I start up my app first and then lose internet connection, my app can access the database fine offline. So why can't it start up without internet?
EDIT: here is the error in full
events.js:85
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at null.<anonymous> (<My App>\node_modules\mongoose\
node_modules\mongodb\lib\mongodb\connection\server.js:555:74)
at emit (events.js:118:17)
at null.<anonymous> (<My App>\node_modules\mongoose\
node_modules\mongodb\lib\mongodb\connection\connection_pool.js:156:15)
at emit (events.js:110:17)
at Socket.<anonymous> (<My App>\node_modules\mongoos
e\node_modules\mongodb\lib\mongodb\connection\connection.js:534:10)
at Socket.emit (events.js:107:17)
at net.js:923:16
at process._tickCallback (node.js:355:11)
[nodemon] app crashed - waiting for file changes before starting...
Edit: wording
Use 127.0.0.1 instead of localhost. By turning off your wifi interface the OS is no longer able to resolve localhost.
Consider node-offline-localhost.
Add the following before the breaking code:
require('node-offline-localhost').always();
And it just works (hopefully), at least until RFC 3493 gets fixed.
Full disclosure: I authored this package to streamline https in my dev environment when offline.

redis getaddrinfo ENOTFOUND - node.js , redis connection

Hi im trying to connect to redis from node.js which is successful, now i hosted my node.js server app on amazon ec2 instance and redis on amazon elastic cache instance the connection to redis is succesful but once in a while i'm getting the below mentioned error.
var pub = redis.createClient(6379,'quizredis.qnsdtp.0001.apse1.cache.amazonaws.com');
events.js:72
throw er; // Unhandled 'error' event
^ Error: Redis connection to quizredis.qnsdtp.0001.apse1.cache.amazonaws.com:6379 failed - getaddrinfo ENOTFOUND
at RedisClient.on_error (/home/ec2-user/roomChat-7/node_modules/redis/index.js:196:24)
at Socket.<anonymous> (/home/ec2-user/roomChat-7/node_modules/redis/index.js:106:14)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:813:16
Im using the redis-npm module;
From what I understand, this is a DNS resolution error.
Elasticache Redis is a VPC specific service. Its DNS records are available within the VPC only and often times, VPC is using custom DHCP options with custom DNS server - it may not have the records.
Check a few things -
DNS server configured in your VPC. Check here.
Check the output of nslookup command in your machine - if your using linux shell
nslookup quizredis.qnsdtp.0001.apse1.cache.amazonaws.com
Cheers!

Error: Connection refused issue when trying to connect to a mqtt enabled node server hosted on heroku

So I basically wanted to host a mqtt pub/sub-enabled node server on Heroku. These are 2 guides I refer to:
https://github.com/adamvr/MQTT.js and https://gist.github.com/1826931
The mqtt pub/sub worked well when tested on localhost, deployment on heroku was fine, but when I tried testing on Heroku it didn't work
I tried 2 commands to subscribe, both showed the same errors.
Command 1:
mosquitto_sub -p <port> -h <host> -t <topic>
Error 1:
Error: Connection refused
Unable to connect (13).
Command 2:
mqtt_sub <port> <host> <topic>
Error 2:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: connect ECONNREFUSED
at errnoException (net.js:670:11)
at Object.afterConnect [as oncomplete] (net.js:661:19)
My main.js (server) code is similar to this one - https://gist.github.com/1826931. The error seems more like a node problem than a mqtt pub/sub problem, and I am new to node, so not quite sure how to debug it. I put in some console.log lines but as expected it didn't print since it's not connected. There is a dyno running node main.js on Heroku fine.
Process State Command
------- ---------- ------------
web.1 up for 35m node main.js
Appreciate any advice on this issue.

Resources