Having a slight issue with connections not being closed when running in "outbound" mode. Based off of the example code but using Srf.
srf.register((req, res) => {
logger.info('srf.register socket:', res.socket);
try {
logger.info({ registration: req.registration }, 'Received an authenticated registration request');
if( 'unregister' === req.registration.type ) {
res.send(200);
} else {
// min_expiry
if (req.registration.expires < 900) {
req.registration.expires = 900;
}
const contactUri = req.registration.contact[0].uri;
res.send(200, {
headers: {
'Contact': '<' + contactUri + '>;expires=' + Math.floor(response.registration.expires / 1000)
}
});
}
} catch (err) {
res.send(503, err.message);
// TODO: handle error accordingly!
} finally {
srf.endSession(res);
}
});
The amount of client connections continues to rise on drachtio-server, and the output from the logging call in the code above for 'res.socket' is as follows:
[2018-04-25T09:06:31.718Z] INFO (1 on tv2-call-router-node-535718781-91n9d): srf.register socket:
{
"connecting": false,
"_hadError": false,
"_handle": {
"bytesRead": 1610,
"_externalStream": {
},
"fd": 194,
"reading": true,
"owner": "[Circular]",
"onconnection": null,
"writeQueueSize": 0
},
"_parent": null,
"_host": null,
"_readableState": {
"objectMode": false,
"highWaterMark": 16384,
"buffer": {
"head": null,
"tail": null,
"length": 0
},
"length": 0,
"pipes": null,
"pipesCount": 0,
"flowing": true,
"ended": false,
"endEmitted": false,
"reading": true,
"sync": false,
"needReadable": true,
"emittedReadable": false,
"readableListening": false,
"resumeScheduled": false,
"destroyed": false,
"defaultEncoding": "utf8",
"awaitDrain": 0,
"readingMore": false,
"decoder": {
"encoding": "utf8",
"lastNeed": 0,
"lastTotal": 0,
"lastChar": {
"type": "Buffer",
"data": [
200,
72,
139,
77
]
}
},
"encoding": "utf8"
},
"readable": true,
"domain": null,
"_events": {
},
"_eventsCount": 7,
"_writableState": {
"objectMode": false,
"highWaterMark": 16384,
"finalCalled": false,
"needDrain": false,
"ending": false,
"ended": false,
"finished": false,
"destroyed": false,
"decodeStrings": false,
"defaultEncoding": "utf8",
"length": 0,
"writing": false,
"corked": 0,
"sync": false,
"bufferProcessing": false,
"writecb": null,
"writelen": 0,
"bufferedRequest": null,
"lastBufferedRequest": null,
"pendingcb": 0,
"prefinished": false,
"errorEmitted": false,
"bufferedRequestCount": 0,
"corkedRequestsFree": {
"next": null,
"entry": null
}
},
"writable": true,
"allowHalfOpen": false,
"_bytesDispatched": 66,
"_sockname": {
"address": "::ffff:10.244.200.177",
"family": "IPv6",
"port": 4000
},
"_pendingData": null,
"_pendingEncoding": "",
"server": {
"domain": null,
"_events": {
},
"_eventsCount": 2,
"_connections": 184,
"_handle": {
"bytesRead": 0,
"_externalStream": {
},
"fd": 10,
"reading": false,
"owner": "[Circular]",
"onread": null,
"writeQueueSize": 0
},
"_usingSlaves": false,
"_slaves": [
],
"_unref": false,
"allowHalfOpen": false,
"pauseOnConnect": false,
"_connectionKey": "6::::4000"
},
"_server": {
"domain": null,
"_events": {
},
"_eventsCount": 2,
"_connections": 184,
"_handle": {
"bytesRead": 0,
"_externalStream": {
},
"fd": 10,
"reading": false,
"owner": "[Circular]",
"onread": null,
"writeQueueSize": 0
},
"_usingSlaves": false,
"_slaves": [
],
"_unref": false,
"allowHalfOpen": false,
"pauseOnConnect": false,
"_connectionKey": "6::::4000"
},
"_peername": {
"address": "::ffff:10.155.250.70",
"family": "IPv6",
"port": 57810
},
"_consuming": true
}
The "_connections": 184, never reduces but just keeps climbing even after calling srf.endSession(res). It gets to the point where the file descriptors are exhausted and we need to restart the application to get rid of the connections.
Authentication is using passport middleware with DigestAuthentication.
Please let me know if you require any additional information. Thanks