englercj / node-esl

FreeSWITCH ESL implementation for Node.js; implements the full Event Socket Library specified in: http://wiki.freeswitch.org/wiki/Esl
http://englercj.github.com/node-esl/
MIT License
170 stars 111 forks source link

cb is not a function Error crashing the esl server #78

Closed axchanda closed 5 years ago

axchanda commented 5 years ago

I get the following error, when executing the node-esl server, be it in server example or ivr example.

/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/modesl/lib/esl/Connection.js:711
            cb(evt);
            ^

TypeError: cb is not a function
    at module.exports.cbWrapper (/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/modesl/lib/esl/Connection.js:711:13)
    at module.exports.EventEmitter.emit (/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/eventemitter2/lib/eventemitter2.js:388:22)
    at module.exports.Connection._onEvent (/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/modesl/lib/esl/Connection.js:797:10)
    at module.exports.EventEmitter.emit (/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/eventemitter2/lib/eventemitter2.js:388:22)
    at module.exports.Parser._parseEvent (/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/modesl/lib/esl/Parser.js:208:10)
    at module.exports.Parser._parseBody (/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/modesl/lib/esl/Parser.js:100:10)
    at module.exports.Parser._parseHeaders (/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/modesl/lib/esl/Parser.js:76:37)
    at module.exports.Parser._parseBody (/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/modesl/lib/esl/Parser.js:103:10)
    at module.exports.Parser._parseHeaders (/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/modesl/lib/esl/Parser.js:76:37)
    at module.exports.Parser._parseBody (/usr/local/freeswitch/scripts/node-esl/examples/server/node_modules/modesl/lib/esl/Parser.js:103:10)

Please let me know what to do!

axchanda commented 5 years ago

@englercj @lxfontes Any updates on this?

englercj commented 5 years ago

Looks like those examples don't pass a callback to execute but the code doesn't check for an undefined callback. Should change this line to change if cb exists before calling it: https://github.com/englercj/node-esl/blob/master/lib/esl/Connection.js#L709

axchanda commented 5 years ago

Commenting that particular line in Connection.js solves this problem. Thanks, anyways @englercj!

englercj commented 5 years ago

Latest master should contain a fix for this issue.