Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange occational exception #116

Open
jonastelzio opened this issue Oct 20, 2021 · 7 comments
Open

Strange occational exception #116

jonastelzio opened this issue Oct 20, 2021 · 7 comments

Comments

@jonastelzio
Copy link
Contributor

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.

@davehorton
Copy link
Collaborator

It looks like an issue parsing an incoming Contact header. Would you be able to correlate it with the incoming SIP request?

@jonastelzio
Copy link
Contributor Author

@davehorton is it possible to somehow get a hold of the SIP Message it failed to parse as part of the error?

@davehorton
Copy link
Collaborator

Its' tough....I would think this would be a incoming message that we did not respond to, probably a register

@jonastelzio
Copy link
Contributor Author

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

@jonastelzio
Copy link
Contributor Author

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!

@jonastelzio
Copy link
Contributor Author

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

@davehorton
Copy link
Collaborator

not sure...can you send the piece of the drachtio log showing the BYE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants