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

Doesn't send PUSH notification because ev->getOutgoingAgent() == NULL #68

Open
brianjmurrell opened this issue Jul 31, 2019 · 11 comments
Open

Comments

@brianjmurrell
Copy link

I've chased down why I'm not getting push notifications.

For reasons beyond my current comprehension of the BC SIP stack, in
PushNotification::onRequest()

shared_ptr<OutgoingTransaction> transaction = dynamic_pointer_cast<OutgoingTransaction>(ev->getOutgoingAgent());

returns NULL and assigns it into transaction, which means that no push
notification is sent:

                if (transaction != NULL) {
                        if (sip->sip_request->rq_url->url_params != NULL) {
                                try {
                                        makePushNotification(ms, transaction);
                                } catch (const runtime_error &e) {
                                        LOGE("Could not create push notification: %s.", e.what());
                                }
                        }
                }

Any ideas or thoughts on why this would be?

@brianjmurrell
Copy link
Author

Nobody has any thoughts on why this would be not working correctly?

@brianjmurrell
Copy link
Author

Is there really nobody who can offer any input or guidance on this issue at all?

@brianjmurrell
Copy link
Author

Why is it that nobody is willing to help with this issue?

@SibertDekimo
Copy link

Hi Brian,

I'm running in this exact same issue. Have you managed to solve it, if so, would you be willing to share your solution?

@brianjmurrell
Copy link
Author

brianjmurrell commented Jan 22, 2020

I gave up on Flexisip a long time ago. I have concluded that it just doesn't work (at least as a push proxy in front of a PBX like Asterisk) and the developers are not willing to help diagnose why -- as can be evidenced by this ticket with absolutely no response whatsoever.

I push from Asterisk directly and don't bother trying to make Flexisip a push proxy for it.

@SibertDekimo
Copy link

SibertDekimo commented Jan 22, 2020

Does your setup work with devices that register after the push, when the call already had been made (aka late forking as its called in Flexisip)? I have a Asterisk server that is able to push notifcations, but devices that need to register when the push is coming don't receive the call at all.

@brianjmurrell
Copy link
Author

Yes it does. I use an AGI script that Asterisk calls when it wants to send a call to a push device. That AGI script doesn't return until the device registers or it times out. That was easy enough to do.

There are some caveats though. Linphone only registers when it's received the push if it doesn't already have a SIP "session" open to the PBX. This generally means that it has not been killed as an idle app by android. So for example, assuming linphone has been killed by android... asterisk sends a push, android receives the push and starts up linphone, which since it is being "started" it registers. The AGI script sees the registration, returns and Asterisk continues it's dialplan and sends an INVITE to Linphone. But let's say as soon as that call is done, another comes in. Because android has not had a chance to kill linphone yet, linphone realizes that it still has a "sesssion" from the call just a few minutes ago and does not re-register because of that. The AGI script now fails to see a registration which allows it to return control back to Asterisk to send the INVITE. This requires that the AGI script be able to determine if linphone has been killed or not. The only way to do this is to use TCP for the SIP signalling and then the AGI queries the open sockets on the system to see if linphone still has an open TCP socket. If it does, it just returns without waiting for a registration

The other caveat is that if linphone is just one of several phones you want to ring for a given extension, it's not really nice to hold up the ringing of non-push extensions while waiting for a push device like linphone, to register as this can take several (up to 10 or more in practical purposes). In order to handle that you need what we think Flexisip is calling "late forking". This is achievable in Asterisk, so that the incoming call sends INVITEs to all of the non-push devices right away and waits for the push devices to register and then sends them their INVITEs.

A third caveat is that none of this works reliably on IPv6. This is a general caveat about SIP clients on mobile devices and has nothing to do with Asterisk or Flexisip, etc. In my experience and from doing a lot of googling, it seems that many phone manufactures put the IPv6 stack to sleep on phones where they don't do the same with IPv4. What this means is that android receives the push, wakes (starts) up linphone and while linphone is able to send IPv4 traffic while the phone is still technically in doze, it is unable to send IPv6 traffic. It believes it is, but the phone is just not sending it out. I (and others) suspect that this is some kind of battery savings mechanism that is needed for IPv6 and not IPv4. Perhaps to do with the amount of "idle" multiicast traffic that IPv6 uses that IPv4 does not. That's just a guess though.

@SibertDekimo
Copy link

Thank you for your very in depth answer. This is probably the way to go! Thanks a lot!

@brianjmurrell
Copy link
Author

NP. I have always intended to write up how I achieved a fully-functioning push configuration for Asterisk in a proper post somewhere. Just haven't found the time.

@SibertDekimo
Copy link

It would be a great start if you could just tell me how your script checks if a device has registered or not. I'm looking at ChanIsAvail and enabling qualify, but I'm not sure if that's the way to go.

@brianjmurrell
Copy link
Author

@SibertDekimo We should take this discussion off of this ticket. I've uploaded my AGI script to https://github.com/brianjmurrell/Android-push-for-Asterisk/blob/master/push.sh. Let's continue any discussion there. You can open a PR or an issue about it if you wish.

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