Skip to content

Astproxy: uncaughtException "Cannot read property 'split' of undefined" on PJSIP contact with public IP and no Call-ID → nethcti-server restart loop #8109

Description

@tonyco97

Description

Steps to reproduce

  • Configure a PJSIP trunk with a static/permanent contact toward a provider on a public IP (e.g. contact = sip:user@203.0.113.5:5060, max_contacts = 0, no inbound REGISTER)
  • Start nethcti-server (astproxy issues PJSIPShowContacts and processes the ContactStatusDetail for that contact)

Expected behavior

astproxy parses the contact details without crashing; nethcti-server stays up.

Actual behavior

astproxy throws and the exception bubbles up to the global uncaughtException handler, which calls process.exit(1). systemd restarts the service, it hits the same contact again → restart loop (observed 1000+ restarts). The CTI is unusable and every login returns 401, because the server never stays up long enough to authenticate.

error: [pjsipDetails] TypeError: Cannot read property 'split' of undefined
    at Object.data (/app/node_modules/@nethesis/astproxy/lib/plugins_command_13/pjsipDetails.js:132:52)
    at AsteriskAmi.onData (/app/node_modules/@nethesis/astproxy/lib/astproxy.js:431:23)
    ...
error: [nethcti] UncaughtException !!!

Root cause

lib/plugins_command_13/pjsipDetails.js:132:

// check if the IP is private otherwise get it from callid
if (!util.isPrivateIP(list[data.actionid].ip)){
  list[data.actionid].ip = data.callid.split('@')[1];   // data.callid may be undefined
}

The code assumes callid is always present. For a statically configured (non-registered) contact, Asterisk sends ContactStatusDetail without a CallID. When such a contact also has a public IP (isPrivateIP returns false), the branch dereferences undefined.split and throws. It never triggers on LAN phones (private IPs skip the branch), so it only surfaces on installations with a public-IP static trunk contact.

Introduced in commit 77b79c4 (#15, "fix(privateIp): added private ip fallback to physical phones"). Still present in 0.0.37 / HEAD.

Suggested fix

Guard callid before splitting:

if (data.callid && !util.isPrivateIP(list[data.actionid].ip)){
  list[data.actionid].ip = data.callid.split('@')[1];
}

Components

  • @nethesis/astproxy 0.0.35 (shipped in ghcr.io/nethesis/nethvoice-cti-server:1.7.3)
  • NethVoice module 1.7.3 on NS8

Metadata

Metadata

Assignees

Labels

nethvoiceBug or features releted to the NethVoice project

Type

Projects

Status
In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions