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

How to handle connection errors? #68

Closed babakyakhchali closed 6 years ago

babakyakhchali commented 6 years ago

Hi how can network errors be handled? something like this: Error: connect ECONNREFUSED 192.168.2.18:8021 constructor only gets a callback which is called after successful connection. but what if esl server is down or not reachable?

englercj commented 6 years ago

Listen for the error event. It will emit anytime an error happens:

var conn = new esl.Connection(...);

conn.on('error', function (err) {
    // handle err
}
babakyakhchali commented 6 years ago

thank you you are right and it is working.

On Thu, Sep 7, 2017 at 3:03 AM, Chad Engler notifications@github.com wrote:

Listen for the error event. It will emit anytime an error happens:

var conn = new esl.Connection(...); conn.on('error', function (err) { // handle err }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/englercj/node-esl/issues/68#issuecomment-327606494, or mute the thread https://github.com/notifications/unsubscribe-auth/AD3Vk7cB2OEeg9qp-3jLysXhptGZtaBNks5sfwNBgaJpZM4POFvx .