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

TypeError: Cannot read property 'recvSSRC' of null #28

Open
garryavx opened this issue Jan 13, 2022 · 3 comments
Open

TypeError: Cannot read property 'recvSSRC' of null #28

garryavx opened this issue Jan 13, 2022 · 3 comments

Comments

@garryavx
Copy link

garryavx commented Jan 13, 2022

I was having issues with my hepipe.js, so I deleted and recloned the repo. installed with npm, setup my config
I'm just capturing rtcp events from the ESL

my config is:

var config = {
  hep_config: {
    debug: true,
    HEP_SERVER: '192.168.20.3',
    HEP_PORT: 9060
  },
  esl_config: {
    debug: true,
    ESL_SERVER: '127.0.0.1',
    ESL_PORT: 8021,
    ESL_PASS: 'ClueCon',
    HEP_PASS: 'freeswitchESL',
    HEP_ID: 2222,
    report_call_events: false,
    report_rtcp_events: true,
    report_qos_events: false,
    report_custom_events: false
  }
};

module.exports = config;

when I run with nodejs hepipe.js it runs for a bit then I get this:

Unique-ID: 79d05382-0dac-423a-b631-19b1dc5e3585
DEFAULT! null
Processing RTCP Report... {
  headers: [
    { name: 'Event-Name', value: 'RECV_RTCP_MESSAGE' },
    {
      name: 'Core-UUID',
      value: '84cb85c5-36fa-4c32-bdba-9202b741b08d'
    },
    { name: 'FreeSWITCH-Hostname', value: 'beta.auravoice.us' },
    { name: 'FreeSWITCH-Switchname', value: 'beta.auravoice.us' },
    { name: 'FreeSWITCH-IPv4', value: '216.128.129.251' },
    { name: 'FreeSWITCH-IPv6', value: '::1' },
    { name: 'Event-Date-Local', value: '2022-01-13 17:21:11' },
    { name: 'Event-Date-GMT', value: 'Thu, 13 Jan 2022 23:21:11 GMT' },
    { name: 'Event-Date-Timestamp', value: '1642116071841091' },
    { name: 'Event-Calling-File', value: 'switch_core_media.c' },
    {
      name: 'Event-Calling-Function',
      value: 'switch_core_media_read_frame'
    },
    { name: 'Event-Calling-Line-Number', value: '3068' },
    { name: 'Event-Sequence', value: '4885560' },
    {
      name: 'Unique-ID',
      value: '79d05382-0dac-423a-b631-19b1dc5e3585'
    },
    { name: 'SSRC', value: '36951dfd' },
    { name: 'NTP-Most-Significant-Word', value: '3851104871' },
    { name: 'NTP-Least-Significant-Word', value: '1022164992' },
    { name: 'RTP-Timestamp', value: '103680000' },
    { name: 'Sender-Packet-Count', value: '106067' },
    { name: 'Octect-Packet-Count', value: '8107388' },
    { name: 'Last-RTP-Timestamp', value: '103680000' },
    { name: 'RTP-Rate', value: '48000' },
    { name: 'Capture-Time', value: '1642116071843040' },
    { name: 'Source0-SSRC', value: '19ea8dff' },
    { name: 'Source0-Fraction', value: '0' },
    { name: 'Source0-Lost', value: '263' },
    { name: 'Source0-Loss-Avg', value: '0' },
    {
      name: 'Source0-Highest-Sequence-Number-Received',
      value: '55272'
    },
    { name: 'Source0-Jitter', value: '199' },
    { name: 'Source0-LSR', value: '845538989' },
    { name: 'Source0-DLSR', value: '124256' },
    { name: 'Rtt0-Avg', value: '0.046655' }
  ],
  hPtr: null,
  type: 'RECV_RTCP_MESSAGE',
  subclass: undefined,
  body: ''
}
/usr/src/hepipe.js/esl-client.js:212
    if (!call.recvSSRC) {
              ^

TypeError: Cannot read property 'recvSSRC' of null
    at getRTCPMessage (/usr/src/hepipe.js/esl-client.js:212:15)
    at module.exports.<anonymous> (/usr/src/hepipe.js/esl-client.js:181:27)
    at module.exports.EventEmitter.emit (/usr/src/hepipe.js/node_modules/eventemitter2/lib/eventemitter2.js:388:22)
    at module.exports.Connection._onEvent (/usr/src/hepipe.js/node_modules/modesl/lib/esl/Connection.js:797:10)
    at module.exports.EventEmitter.emit (/usr/src/hepipe.js/node_modules/eventemitter2/lib/eventemitter2.js:388:22)
    at module.exports.Parser._parseEvent (/usr/src/hepipe.js/node_modules/modesl/lib/esl/Parser.js:208:10)
    at module.exports.Parser._parseBody (/usr/src/hepipe.js/node_modules/modesl/lib/esl/Parser.js:100:10)
    at module.exports.Parser._parseHeaders (/usr/src/hepipe.js/node_modules/modesl/lib/esl/Parser.js:76:37)
    at module.exports.Parser._onData (/usr/src/hepipe.js/node_modules/modesl/lib/esl/Parser.js:36:21)
    at Socket.emit (events.js:314:20)
@garryavx
Copy link
Author

I am. so confused.

I asked a friend to help and he suggested commenting out part of line 209 to set it to null.
var call = "";
instead of
var call = db.get(e.getHeader('Unique-ID'));
and now it works.

also my output in the console still has Unique-IDs and homer seems to ingest all the data fine and show everything...?

@babakyakhchali
Copy link

The bug is related to calls not existing in DB and receiving a RTCP event related to it, the uuid of the call in event is not in db so no call is found and the call variable is undefined, this will happen for calls created before starting the script. The issue can be fixed like this:

var getRTCPMessage = function (e, xcid, hep_id, hep_pass) {
  var call = db.get(e.getHeader('Unique-ID'));
  
  if(!call){
	  console.log('call not found in db!',e.getHeader('Unique-ID'));
	  return;
  }

and

if (report_rtcp_events) {
        if (e.getHeader('Event-Name') == 'RECV_RTCP_MESSAGE' || e.getHeader('Event-Name') == 'SEND_RTCP_MESSAGE') {
          if (e.getHeader('Source0-SSRC') || e.getHeader('Source-SSRC')) {
            if (debug) console.log('Processing RTCP Report...', e);
            var message = getRTCPMessage(e, xcid, hep_id, hep_pass);
			if(message){
				callback_preHep(message);
			}
            
          }
        }
      }

@blerest
Copy link

blerest commented Jul 27, 2022

@babakyakhchali this fix issue. Does it possible to create a PR with that fix?

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

3 participants