Skip to content

Instantly share code, notes, and snippets.

@alejandro
Created May 15, 2012 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alejandro/525f55a7a2c457af2981 to your computer and use it in GitHub Desktop.
Save alejandro/525f55a7a2c457af2981 to your computer and use it in GitHub Desktop.
# if i don't parseInt the app_port var i get this
> app_port=2131 node server
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object 2131 has no method 'on'
at new Manager (/home/alejandromg/9539-92fd447a71e931bda296344ae90b9f48/node_modules/socket.io/lib/manager.js:101:10)
at Object.listen (/home/alejandromg/9539-92fd447a71e931bda296344ae90b9f48/node_modules/socket.io/lib/socket.io.js:71:10)
at Object.<anonymous> (/home/alejandromg/9539-92fd447a71e931bda296344ae90b9f48/server.js:4:31)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
// this works
var PORT = parseInt(process.env['app_port'],10) || 3000;
var io = require("socket.io").listen( PORT, function(){
io.sockets.on("connection",arrancar);
function arrancar(msg){
msg.on("nuevoMensaje",emitir);
}
function emitir(data){
io.sockets.emit("mensaje",data);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment