diff --git a/package.json b/package.json index 6741546..0a60dcf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uci/socket", - "version": "0.2.12", + "version": "0.2.13", "description": "JSON packet intra(named)/inter(TCP) host communication over socket", "main": "src", "scripts": { diff --git a/src/socket-class.js b/src/socket-class.js index be4f9d6..cfe5ec8 100644 --- a/src/socket-class.js +++ b/src/socket-class.js @@ -171,6 +171,20 @@ export default function socketClass(Server) { log.debug({method:'_listen', line:171, conPacket: this.opts.conPacket, msg:'pushing a preset command to just connected consumer'}) send(await stream.serialize(this.opts.conPacket)) // send a packet command on to consumer on connection } + + // add error and close listeners on connection + socket.on('error', (err) => { + log.error({msg:'client connection error during listen',error:err}) + }) + + socket.on('close', (msg) => { + log.warn({msg:'client connection closed during listen',error:msg}) + }) + + stream.on('error', (err) => { + log.error({msg:'client-socket stream error during listen',error:err}) + }) + socket.on('data', stream.onData) // TODO need to start error listener for stream so errors can be processed stream.on('message', messageProcess.bind(this, socket))