0.2.13 add better error handling to avoid reconnrest execpetion

master
David Kebler 2019-04-28 09:58:15 -07:00
parent 072dd25dc4
commit 456b9568ff
2 changed files with 15 additions and 1 deletions

View File

@ -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": {

View File

@ -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))