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

BridgeCreated and BridgeDestroyed aren't catch #110

Open
mbayou opened this issue Jun 19, 2018 · 7 comments
Open

BridgeCreated and BridgeDestroyed aren't catch #110

mbayou opened this issue Jun 19, 2018 · 7 comments

Comments

@mbayou
Copy link

mbayou commented Jun 19, 2018

Hi,

I'm trying to listen theses two events BridgeCreated and BridgeDestroyed but I do not get any information.

        ari.start('my-app');

        // ... create bridge and channels (All this part works well)

        // Theses parts below are never call
        ari.on("BridgeCreated", (event, bridge) => {
            console.log("Bridge created");
        });

        ari.on("BridgeDestroyed", (event, bridge) => {
            console.log("Bridge destroyed");
        });

I didn't find any people who complain about that, then I think I made a mistake somewhere. Is that the right way to catch up theses events ?

Thanks for your answer

@samuelg
Copy link
Contributor

samuelg commented Jun 19, 2018

You may want to move ari.start('my-app'); under where you register for events. There could technically be an event that fires while you are registering for it.

I don't see where you are creating a bridge. By default you'll only get events for the bridges you create inside your Stasis app.

@mbayou
Copy link
Author

mbayou commented Jun 21, 2018

Hi @samuelg,

It's more complicated, I tried to simplify a little bit this example. So I have an application with Inversify and the ari is like a service which the other services depends on. And the subscription is an other service that create subscription for websocket client.

My bridge is created inside another service but like I said all works with the channel and bridge creation, also I get theses other events without any difficulty: ChannelEnteredBridge, ChannelLeftBridge, ChannelDestroyed, Dial, ChannelStateChange.

My only trouble comes from theses two events above.

Thanks for your help.

@samuelg
Copy link
Contributor

samuelg commented Dec 17, 2018

Bridges can be reused so it's possible an existing bridge (unused) bridge was used. Without knowing how your application is interacting with bridges/channels it's hard to tell what might be wrong.

Are you creating/destroying said bridges yourself? You might not get the events if the bridges are being created/destroyed by another app unless you register for bridge events. The events you are getting you list above are technically Channel events. As long as your application is handling StasisStart events or originating the channels, you'll be auto subscribed to the Channel events which is why you would be receiving them but not necessarily receiving Bridge events.

Hope that helps.

@MattRiddell
Copy link

Yeah I'm having the same problem.

I'm trying to maintain state even over crashes so I do the following:

Save bridges to DB when created/delete when destroyed
If I start up and there are empty bridges I clear them
If I start up and there are non empty bridges I'd like to clean them up when they are destroyed

I have:

ari.on('BridgeDestroyed', destroyBridge);

but the function doesn't get called when the bridge is destroyed.

Is there a better way to know that this has happened so I can clear it out of my DB?

@MattRiddell
Copy link

Looks like in my case I should be able to subscribe my application to the bridge but I can't see how to do that from ari-client

@MattRiddell
Copy link

I didn't get the bridge destroyed but I guess that's because it just sits there empty. I subscribed to the channel destroyed and then checked for empty bridges to destroy and it worked fine.

@timo-klarshift
Copy link

You only would receive those events if you use subscribeAll=true or if you explicitly subscribe to the bridges eventSource, see here: https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Applications+REST+API#Asterisk13ApplicationsRESTAPI-subscribe

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

4 participants