drachtio-srf
drachtio-srf copied to clipboard
Strange occational exception
Hi there,
So, I'm getting these exceptions occasionally, but I'm not quite sure what it's about:
TypeError: Cannot read property 'length' of undefined
at parseMultiHeader (/app/node_modules/drachtio-srf/node_modules/drachtio-sip/lib/parser.js:85:22)
at contact (/app/node_modules/drachtio-srf/node_modules/drachtio-sip/lib/parser.js:161:14)
at SipMessage.getParsedHeader (/app/node_modules/drachtio-srf/node_modules/drachtio-sip/lib/message.js:91:12)
at new Dialog (/app/node_modules/drachtio-srf/lib/dialog.js:71:39)
at /app/node_modules/drachtio-srf/lib/srf.js:284:24
at DrachtioAgent.<anonymous> (/app/node_modules/drachtio-srf/lib/drachtio-agent.js:346:11)
at DrachtioAgent._onMsg (/app/node_modules/drachtio-srf/lib/drachtio-agent.js:727:11)
at WireProtocol.emit (node:events:369:20)
at WireProtocol.emit (node:domain:470:12)
at WireProtocol.processMessageBuffer (/app/node_modules/drachtio-srf/lib/wire-protocol.js:270:12)
It's being caught by this code:
process.on('uncaughtException', (err) => {
console.error("uncaught exception", err);
});
What I can see, else where in my code, is that req.receivedOn
is undefined, but I'm not sure how that's possible. I'm running in Outbound mode, which could be relevant I reckon(?).
I've tried correlating these logs with drachtio-servers, but I've found nothing particularly interesting, and I can't explicitly find out what causes this, so I'm not effectively able to just enable full debugging on SRF in hopes to find out what's going on.
We're getting these in production, and they do seem harmless, but still, they're errors.
It looks like an issue parsing an incoming Contact header. Would you be able to correlate it with the incoming SIP request?
@davehorton is it possible to somehow get a hold of the SIP Message it failed to parse as part of the error?
Its' tough....I would think this would be a incoming message that we did not respond to, probably a register
I've added this now:
//Drachtio server ip middleware
srf.use((req, res, next) => {
try {
let drachtioServerIp = req.receivedOn;
const colonLocation = drachtioServerIp.indexOf(':');
if (colonLocation > 0) {
drachtioServerIp = drachtioServerIp.substring(0, colonLocation);
}
req.telzioContext.drachtioServerIp = drachtioServerIp;
debug(`SRF ${req.method} Request from ${drachtioServerIp}`);
}
catch (e) {
req.telzioContext.logger.error("Exception in drachtio server ip middleware", e, {sip_raw: req.msg.raw});
throw e;
}
next();
});
That'll at least get me the SIP Message logged next time it happens
I've not seen this exception in quite a while. Perhaps it went away when upgrading to a more recent version of the drachtio-srf package!
@davehorton
I've gotten this error again, and it turns out it's a BYE request with both a to/from tag - so not a dialog forming request.
Any idea what would cause something like that to end up in middleware like that?
not sure...can you send the piece of the drachtio log showing the BYE?