asterisk / node-ari-client

Node.js client for ARI. This library is best effort with limited support.
Other
253 stars 99 forks source link

Half open socket connections, ping events #104

Closed jp1987 closed 6 years ago

jp1987 commented 6 years ago

I am running into problems with half open socket connections when connecting to Asterisk over VPN. To fix this, the ping/pong mechanism should implemented as is described here. Right now, as far as I know, it's not possible to send the ping event and/or receive the pong event.

jp1987 commented 6 years ago

Pseudo code based on this PR:

ari.connect(url, user, pass, (err, client) => {

    client.on('pong', () => {
        console.log('pong');
    });

    client.on('WebSocketConnected', () => {
        setInterval(() => {
            client.ping();
        }, 30000);
    });  
});