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

endPoint.play does not return if call end by RemoteParty #9

Open
haeferer opened this issue Nov 23, 2018 · 8 comments
Open

endPoint.play does not return if call end by RemoteParty #9

haeferer opened this issue Nov 23, 2018 · 8 comments

Comments

@haeferer
Copy link

haeferer commented Nov 23, 2018

we have a sample conneting to a local PhonerLite.

AsyncMain(process.mainModule == module, async () => {
    const srf = new Srf();
    srf.connect({host: '172.22.17.11', port: 9022, secret: 'cymru'});
    let hostport = await waitForEvent<string>(srf, 'connect');
    console.log('Connected ', hostport);
    const mrf = new Mrf(srf);
    let mediaserver = await mrf.connect({listenAddress: '172.22.17.9', address: '172.22.17.11', port: 8021, secret: 'ClueCon'});
    console.log('MediaServer Available');
    let endPoint = await mediaserver.createEndpoint();
    console.log('Endpoint created',endPoint.local.sdp);
    let dialog = await srf.createUAC('sip:ahr@172.22.17.9:5070', {
        localSdp: endPoint.local.sdp,
    }, {
        cbRequest: (err,req, res) => {
            console.log('CbReq...', err, );
        },
        cbProvisional: (res) => {
            console.log('ProvisionalResp...',res.status+' '+res.reason)
        }
    });
    await endPoint.dialog.modify(dialog.remote.sdp);
    dialog.on('destroy', (msg, reason) => {
        endPoint.destroy();
        console.log('got bye', reason);
    })
    console.log('Established');
    await waitFor(1000);
    await endPoint.play(['silence_stream://1000', 'voicemail/8000/vm-record_message.wav']);
    console.log('Done Playing')
    await endPoint.execute('send_dtmf', '1234@100');
    // console.log('done Play file');
    let answer = await endPoint.playCollect({file: 'silence_stream://200', min: 1, max: 4});
    console.log(answer);
    await waitFor(5*1000);
    console.log('Dest. Dialog');
    await dialog.destroy();
    console.log('Done');

});

The Playback works, but if the remoteparty (Phonerlite) hangs up during playback the Promise

await endPoint.play(['silence_stream://1000', 'voicemail/8000/vm-record_message.wav']);

never ends...

The destroy event from Dialog is fired

console.log('got bye', reason);
@haeferer
Copy link
Author

haeferer commented Nov 23, 2018

The Result is the same with or without

await endPoint.dialog.modify(dialog.remote.sdp);

It is realy needed to Populate the remote.sdp (i think so?)

@davehorton
Copy link
Collaborator

Yes, this is how it currently works. If you destroy the Endpoint (as you do in the 'destroy' handler for the sip dialog) then any operations are terminated by freeswitch and those promises won't resolve .

I suppose it would be more correct to have those promises be rejected (or callbacks invoked with an error) that indicate the call / session was terminated? In practice, I have never had the need to want to receive those since once the call is over I implicitly know all operations have ceased and I mostly proceed to doing my cleanup code. I can take a deeper look at this, but would be good to know what you expect....a Promise rejection, as I suggest above?

@haeferer
Copy link
Author

haeferer commented Nov 23, 2018 via email

@haeferer
Copy link
Author

haeferer commented Nov 23, 2018 via email

@haeferer
Copy link
Author

haeferer commented Nov 24, 2018 via email

@haeferer
Copy link
Author

we had solved the problem by implementing a BreakablePromise. This class implements a Set of Promises. If an event (like destroy) occurs, all promises in unresolved( like on .play or .playCollect) will be broken (resolved) with a special error.

@davehorton
Copy link
Collaborator

ok. I'm still going to look into properly resolving/rejecting those promises. let's leave this issue open until I do so.

@haeferer
Copy link
Author

haeferer commented Nov 30, 2018 via email

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

2 participants