fix(pjsip): guard undefined callid on non-private contact - #33
Open
tonyco97 wants to merge 1 commit into
Open
Conversation
tommaso-ascani
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
astproxy crashes with an uncaught
TypeError: Cannot read property 'split' of undefinedatpjsipDetails.jswhen processing aContactStatusDetailfor a PJSIP contact that has a public IP and no Call-ID.The exception bubbles up to the global
uncaughtExceptionhandler innethcti-server, which callsprocess.exit(1). systemd restarts the service, it hits the same contact again → restart loop (observed 1000+ restarts on a customer install). The CTI becomes unusable and every login returns 401 because the server never stays up.Root cause
data.callid.split('@')[1]assumescallidis always present. For a statically configured (non-registered) contact — typical of a provider trunk with a permanentcontact=andmax_contacts=0— Asterisk sendsContactStatusDetailwithout aCallID. When such a contact also has a public IP (isPrivateIPreturns false), the code enters the branch and dereferencesundefined.It never triggers on LAN phones (private IPs skip the branch), so it only surfaces on installs with a public-IP static trunk contact.
Fix
Guard
callidbefore splitting. When absent, keep the IP already derived fromviaaddress/uri.Regression analysis
callidpresent (normal registered phones): behavior identical — the private-IP fallback (fix(privateIp): added private fallback to physical phones #15) still works.callidabsent + public IP (static trunk): previously fatal crash, now keeps the via/uri IP..ipis display-only (exposed viatoJSON, shown in the CTI); it is not used for call routing or auth.Fixes NethServer/dev#8109