Socket.io server not working - node.js

I've got a Socket.io server that is not working (it shows the following error on Firebug and of course it doesn't any of its functions):
GET http://www.example.com:1618/socket.io/1/?t=1401400488401 400 Bad Request 35ms
Also, when I try to run the server, it outputs that:
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at net.js:1146:9
at asyncCallback (dns.js:68:16)
at Object.onanswer [as oncomplete] (dns.js:121:9)
I am running it on Ubuntu 14.04

EADDRINUSE means that there is another process that is listening to the port you're using for socket.io. Try changing the port number for socket.io when listen() is called.
On ubuntu, you might need to run it with sudo:
sudo nodejs your_server.js

Related

When running or lifting sails/nodeJS application Error: listen EADDRINUSE

events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1039:14)
at listen (net.js:1061:10)
at Server.listen (net.js:1135:5)
at Array.async.auto.start [as 0] (/var/www/html/zentiera/node_modules/sails/lib/hooks/http/start.js:29:35)
While using sails js or node js, The error may create difficulties in newbies of technology.
This specially comes when we try to stop the application using (ctrl+z)
and unfortunately the error creates while restarting it
^Z
[1]+ Stopped sails lift
There are 2 methods to recover this situation :
Need to kill the previous port
fuser -k 9002/tcp
Declare a different port number in your application
localhost//config/local.js
port: process.env.PORT || newPortNumber,

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.

Node.js throws the below "events.js:72 throw er; // Unhandled 'error' even"

I am running one .js script and new to the node.js, I am getting below errors:
2014-08-12 23:24:20.986 UTC - Server running at 10.11.6.249:9090
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 Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:906:3
Not sure why these errors are I have closed the port 8000 and re-launch app as well, still facing the same issue.
It is not a problem of port (through I don't understand 8000 or 9090) it is a problem of IP address. Either it was changed and is hardcoded, or IP conflict in network. Run it with 127.0.0.1

error message, node project installation on server?

Im trying to start my node project on my node server but I keep getting a error message, the server is ready to use node, I already have some other projects installed on it but this I can't understand. Can anyone understand this error message?
events.js:69
throw arguments[1]; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:850:11)
at Server._listen2 (net.js:995:14)
at listen (net.js:1022:10)
at Server.listen (net.js:1071:5)
at Function.app.listen (/srv/www/ikonset.com/node_modules/express/lib/application.js:531:24)
The error EADDRINUSE means you already have a process bound to the port you're trying to listen on (3000 or whatever). What you should do is first STOP your other process on that port, then restart your Node app.

Forever Crashes and Doesn't Restart after 4 times

I have a node server running on AWS and I am using forever to keep it running in the background.
I have been very happy with forever so far; it's super easy to set up and use. However, even though my app is very simple, sometimes it crashes with this error:
Express server listening on port 3001
events.js:72
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
error: Forever detected script exited with code: 8
error: Forever restarting script for 4 time
When I look back at the logs, I can see that this has happened 4 more times, and each time forever manages to restart the server. However, when it happens for the 5th time, for some reason forever fails to restart the server and my app becomes unresponsive.
Express server listening on port 3001
events.js:72
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
error: Forever detected script exited with code: 8
/usr/lib/node_modules/forever/node_modules/forever-monitor/node_modules/broadway/node_modules/eventemitter2/lib/ev$
throw arguments[1]; // Unhandled 'error' event
^
Error: Cannot stop process that is not running.
at /usr/lib/node_modules/forever/node_modules/forever-monitor/lib/forever-monitor/monitor.js:332:26
at process._tickCallback (node.js:415:13)
Has anyone else experienced similar problems?
You have to use the option -MAX like this:
forever -MAX 10000000000 Mypath/ToMyFile.js
Also put a -minUptime for the minimum time the server can stay up, if it crash before that laps of time then it won't go up again so set it to 1.
forever --minUptime (number-in-milisecond-here) -MAX (number-of-restart-here) path/file.js
Just try this:
forever --minUptime 1 -MAX 1000000000 YourPath/ToYourFile.js
More documentation there
https://www.npmjs.com/package/forever
To allow a max of 100 restarts when the server crashes
forever start -m 100 index.js

Resources