Foros del Web » Programando para Internet » Node.js »

[SOLUCIONADO] events.js:72 throw er; // Unhandled 'error' event

Estas en el tema de events.js:72 throw er; // Unhandled 'error' event en el foro de Node.js en Foros del Web. Hola. Hace un tiempo comence un proyecto con node.js, un servidor UDP utilizando la libreria Dgram nativa en node. El servidor recibe datagramas y responde ...
  #1 (permalink)  
Antiguo 14/04/2015, 17:40
 
Fecha de Ingreso: julio-2013
Mensajes: 13
Antigüedad: 10 años, 9 meses
Puntos: 0
events.js:72 throw er; // Unhandled 'error' event

Hola.
Hace un tiempo comence un proyecto con node.js, un servidor UDP utilizando la libreria Dgram nativa en node.
El servidor recibe datagramas y responde inmediatamente al remitente (host, port)
alrededor de las 180 respuestas del server me da este error:

events.js:72
throw er; // Unhandled 'error' event

instale el WireShark para monitorear el puerto (4096 que utilizo para recibir y enviar)
y solo lo utiliza node.js.

Alguien tiene alguna sugerencia??
  #2 (permalink)  
Antiguo 14/04/2015, 18:48
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: events.js:72 throw er; // Unhandled 'error' event

Sin ver el código no se puede adivinar.

Saludos
__________________
Grupo Telegram Docker en Español
  #3 (permalink)  
Antiguo 14/04/2015, 19:22
 
Fecha de Ingreso: julio-2013
Mensajes: 13
Antigüedad: 10 años, 9 meses
Puntos: 0
Respuesta: events.js:72 throw er; // Unhandled 'error' event

server.js
Código:
var dgram	=		require("dgram");
var server	=	dgram.createSocket("udp4");
var funcion	=	require("./funciones.js");
var enviar	=	require("./sendUdp.js");

server.on("error", function (err) {
  console.log("server error: " + err.stack);
  server.close();
});

server.on("message", function (msg, rinfo) {

	enviar.sendUdp(rinfo.address,rinfo.port,msg);
	
});

server.on("listening", function () {
  var address = server.address();
  console.log("Servidor Iniciado " +
      address.address + ":" + address.port);
});

server.bind(4096);
sendUdp.js
Código:
function sendUdp(host,port,trama){
	var dgram 		= 	require('dgram');
	var funcion		= 	require("./funciones.js");
	var BaseDeDatos	= 	require("./mysql.js");
	var HOST 		= 	host;
	var PORT 		= 	4096; // Salida del Server
	

	var tramaAComparar	=	trama.toString().split('*');
	if(funcion.calcChecksum(tramaAComparar[0]) == funcion.buscarChecksum(trama)  ){
	
	var client		= dgram.createSocket('udp4');
		client.bind(PORT);
		
		var msj = '>ACK;' + funcion.ParsearSentencia(trama)[0] +';' 
		+ funcion.ParsearSentencia(trama)[1] + ';';
		var msj_mas_checksum = msj + funcion.calcChecksum(msj) +"<";
		
		var message	= new Buffer(msj_mas_checksum.toString());
		console.log("Servidor Responde: " + msj_mas_checksum);
	
		
		client.send(message, 0, message.length, port, HOST, function(err, bytes) {
		if (err) throw err;
		client.close();
		console.log('UDP message sent to ' + HOST +':'+ port);
		BaseDeDatos.grabar(funcion.ParsearSentencia(trama.toString()));
		
				}); 
	


		}
	else{
		console.log(trama);
		var tramaAComparar	=	trama.toString().split('*');
		console.log("Error en Checksum Recibido!! " + 
		funcion.calcChecksum(tramaAComparar[0]) + " " +
		funcion.buscarChecksum(trama));
		
		
	}
	
	



}; 
exports.sendUdp = sendUdp;
funciones.js
Código:
function calcChecksum(cmd)
{
  /* Calcular la suma de comprobación por XOR
   todos los valores de caracteres en la cadena cmd   */ 
   
  var checksum = 0;
  for(var i = 0; i < cmd.length; i++) {
    checksum = checksum ^ cmd.toString().charCodeAt(i);
  }

  // Convertirlo a hexadecimal 
  var tmp, hexsum = Number(checksum).toString(16).toUpperCase();
  if (hexsum.length < 2) {
    hexsum = ("00" + hexsum).slice(-2);
  }
  return tmp = "*" + hexsum;
}

function buscarChecksum(chk){
	var 	 posicion =  chk.toString().indexOf("*");
	return   chk.toString().substring(posicion, posicion + 3);	
} 

function ParsearSentencia(trama){
	var arrays	=	trama.toString().split(';');	
	var fecha	=	20 + trama.toString().substring(8, 10) + "-" + trama.toString().substring(6,8) + "-" +trama.toString().substring(4,6);
	var hora	=	trama.toString().substring(10,12) + ":" + trama.toString().substring(12,14) + ":" + trama.toString().substring(14,16);
	var latitud	=	trama.toString().substring(16,19) + "." + trama.toString().substring(19,24);
	var longitud =  trama.toString().substring(24,28) + "." + trama.toString().substring(28,33);
	var velocidad = trama.toString().substring(33,36);
	var direccion = trama.toString().substring(36,39);
	var posicion =	trama.toString().substring(39,40);
	var edadDato =	trama.toString().substring(40,42);
	var entradas =	trama.toString().substring(42,44);
	var nroEvento = trama.toString().substring(44,46);
	var prescionHorizontal = trama.toString().substring(46,48);
	var dato	=	trama.toString();
	var res	=		[ fecha, hora, latitud, longitud, velocidad, direccion, posicion, edadDato, entradas, nroEvento, prescionHorizontal, dato];
	var resultado = [arrays[1], arrays[2]].concat(res);

	return resultado;
}
exports.calcChecksum = calcChecksum;
exports.buscarChecksum = buscarChecksum;
exports.ParsearSentencia = ParsearSentencia;
mysql.js
Código:
function grabar (trama){
	
	var mysql      = require('mysql');
	var connection = mysql.createConnection({
	host     : 'localhost',
	user     : 'user',
	password : 'paSS',
	database : 'DATABASE'
	});
 
	connection.connect();
	var post  = {id: '', id_equipo: trama[0].substring(3,7) ,fecha_hora: trama[2] + " " + trama[3], fecha_equipo: trama[2], hora_equipo:trama[3] , latitud: trama[4], longitud: trama[5], velocidad: trama[6], direccion: trama[7], entradas: trama[10], trama: trama[13] };
	var query = connection.query('INSERT INTO datogps SET ?', post, function(err, result) {
	//console.log(err);
	});
 
 
	connection.end();
 
}
exports.grabar = grabar;

Última edición por electronicarbb; 14/04/2015 a las 20:01
  #4 (permalink)  
Antiguo 15/04/2015, 08:07
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: events.js:72 throw er; // Unhandled 'error' event

Y el error completo.

Saludos
__________________
Grupo Telegram Docker en Español
  #5 (permalink)  
Antiguo 15/04/2015, 08:14
 
Fecha de Ingreso: julio-2013
Mensajes: 13
Antigüedad: 10 años, 9 meses
Puntos: 0
Respuesta: events.js:72 throw er; // Unhandled 'error' event

Ese es todo el error que me da:

Servidor Responde: >ACK;ID=9727;#157D;*23<
UDP message sent to 201.251.189.209:40608

events.js:72
throw er; // Unhandled 'error' event
^

Uso node.js v0.10.36
es la unica version que pude hacer funcionar en Windows 7 32btis
  #6 (permalink)  
Antiguo 15/04/2015, 08:28
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: events.js:72 throw er; // Unhandled 'error' event

Debería mostrarte un stacktrace completo, ¿eso es todo lo que sale en la consola?
__________________
Grupo Telegram Docker en Español
  #7 (permalink)  
Antiguo 15/04/2015, 08:36
 
Fecha de Ingreso: julio-2013
Mensajes: 13
Antigüedad: 10 años, 9 meses
Puntos: 0
Respuesta: events.js:72 throw er; // Unhandled 'error' event

Asi es, Puedo crear alguna funcion para que me muestre el error?
  #8 (permalink)  
Antiguo 17/04/2015, 05:02
 
Fecha de Ingreso: julio-2013
Mensajes: 13
Antigüedad: 10 años, 9 meses
Puntos: 0
Respuesta: events.js:72 throw er; // Unhandled 'error' event

A nadie le paso esto?
  #9 (permalink)  
Antiguo 17/04/2015, 23:44
Avatar de jsstoni  
Fecha de Ingreso: enero-2015
Ubicación: Maracaibo
Mensajes: 82
Antigüedad: 9 años, 3 meses
Puntos: 4
Respuesta: events.js:72 throw er; // Unhandled 'error' event

cambia de puerto a 8080 para ver.

y eso no puede ser el error despues de ^ te dice que modulo estan mal y en que linea.
__________________
Desarrollo web Front End Realtime NodeJs
  #10 (permalink)  
Antiguo 18/04/2015, 20:20
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: events.js:72 throw er; // Unhandled 'error' event

Ese solo es error final, debería mostrar un traceback, sin crear una función propia, por lo menos una donde venga la linea donde ocurre eso.
__________________
Grupo Telegram Docker en Español
  #11 (permalink)  
Antiguo 04/05/2015, 08:25
 
Fecha de Ingreso: julio-2013
Mensajes: 13
Antigüedad: 10 años, 9 meses
Puntos: 0
Respuesta: events.js:72 throw er; // Unhandled 'error' event

sigo rompiendome la cabeza tratando de saber donde esta el error, en consola solo me sale eso : events.js:72 throw er; // Unhandled 'error' event.
ese mensaje pertenece a una linea de el archivo events.js de node y lo muestra tal cual esta en el archivo con ese comentario.
este es el link del archivo:
https://github.com/joyent/node/blob/ef4344311e19a4f73c031508252b21712b22fe8a/lib/events.js

ahi lo muestra en la linea 87 (por los comentarios en la cabecera)

esta es la funcion dentro del archivo donde detecta el error.
Código:
EventEmitter.prototype.emit = function emit(type) {
  var er, handler, len, args, i, listeners;

  if (!this._events)
    this._events = {};

  // If there is no 'error' event listener then throw.
  if (type === 'error' && !this._events.error) {
    er = arguments[1];
    if (this.domain) {
      if (!er)
        er = new Error('Uncaught, unspecified "error" event.');
      er.domainEmitter = this;
      er.domain = this.domain;
      er.domainThrown = false;
      this.domain.emit('error', er);
    } else if (er instanceof Error) {
  throw er; // Unhandled 'error' event
    } else {
      throw Error('Uncaught, unspecified "error" event.');
    }
    return false;
  }

  handler = this._events[type];

  if (util.isUndefined(handler))
    return false;

  if (this.domain && this !== process)
    this.domain.enter();

  if (util.isFunction(handler)) {
    switch (arguments.length) {
      // fast cases
      case 1:
        handler.call(this);
        break;
      case 2:
        handler.call(this, arguments[1]);
        break;
      case 3:
        handler.call(this, arguments[1], arguments[2]);
        break;
      // slower
      default:
        len = arguments.length;
        args = new Array(len - 1);
        for (i = 1; i < len; i++)
          args[i - 1] = arguments[i];
        handler.apply(this, args);
    }
  } else if (util.isObject(handler)) {
    len = arguments.length;
    args = new Array(len - 1);
    for (i = 1; i < len; i++)
      args[i - 1] = arguments[i];

    listeners = handler.slice();
    len = listeners.length;
    for (i = 0; i < len; i++)
      listeners[i].apply(this, args);
  }

  if (this.domain && this !== process)
    this.domain.exit();

  return true;
};

Última edición por electronicarbb; 04/05/2015 a las 09:00
  #12 (permalink)  
Antiguo 06/05/2015, 18:27
 
Fecha de Ingreso: julio-2013
Mensajes: 13
Antigüedad: 10 años, 9 meses
Puntos: 0
Respuesta: events.js:72 throw er; // Unhandled 'error' event

voy a tener que buscar otro lenguaje? quisas hacerlo en C?
  #13 (permalink)  
Antiguo 11/05/2015, 07:51
 
Fecha de Ingreso: julio-2013
Mensajes: 13
Antigüedad: 10 años, 9 meses
Puntos: 0
Respuesta: events.js:72 throw er; // Unhandled 'error' event

Bueno, parece que no tengo suerte en este foro; voy a probar suerte en otro
  #14 (permalink)  
Antiguo 11/05/2015, 09:33
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: events.js:72 throw er; // Unhandled 'error' event

Muchacho, lo que pasa es que no das suficiente información, personalmente no me voy a poner a debuggear tu código y dudo que alguien lo haga.
__________________
Grupo Telegram Docker en Español
  #15 (permalink)  
Antiguo 19/05/2015, 14:22
 
Fecha de Ingreso: julio-2013
Mensajes: 13
Antigüedad: 10 años, 9 meses
Puntos: 0
Respuesta: events.js:72 throw er; // Unhandled 'error' event

Cita:
Iniciado por Carlangueitor Ver Mensaje
Muchacho, lo que pasa es que no das suficiente información, personalmente no me voy a poner a debuggear tu código y dudo que alguien lo haga.
No pretendia que nadie me solucione el problema, si no que me oriente al menos.....
Asi que:
* NO VOY A DECIR DONDE ESTABA EL PROBLEMA;
* NI COMO LO SOLUCIONE.

desde ya muchas gracias
  #16 (permalink)  
Antiguo 19/05/2015, 14:48
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: events.js:72 throw er; // Unhandled 'error' event

Como si fueras el único que puede resolverlo.
__________________
Grupo Telegram Docker en Español

Etiquetas: event
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:19.