flexisip icon indicating copy to clipboard operation
flexisip copied to clipboard

Receives INVITE, sends push notification and then doesn't wait for linphone to connect

Open brianjmurrell opened this issue 5 years ago • 56 comments

I've got a flexisip installation here proxying an Asterisk instance with a Linphone feature/release-4.1 client enabled for push.

If I make a call to the linphone client after it registers to the proxy and is still running on the phone everything works fine.

However if I terminate the linphone client (recall, enabled for push, so this should work fine), when flexisip receives the INVITE from Asterisk to forward to linphone, it sends a push notification to the firebase server and then immediately tries to send an INVITE to linphone. That INVITE is of course refused because linphone has not had enough time to start and REGISTER in response to the push, but flexisip then immediately responds to asterisk with a 503 response.

Shouldn't there be some waiting and retrying going on here to allow linphone to be woken and REGISTER rather than immediately sending a 503 to the PBX?

Here's the flexisip log.

brianjmurrell avatar Apr 03 '19 13:04 brianjmurrell

Any thoughts on this?

I can't see how flexisip, as a push proxy is at all usable given the way it handles the above scenario.

I'd just like to know if I should give up on flexisip and roll my own solution.

brianjmurrell avatar Apr 05 '19 10:04 brianjmurrell

Install: aptitude install bc-flexisip = 1.0.13-198 (it may be a bit earlier or later versions). Most new versions with Push stopped working altogether.

SafeSoft-tlt avatar Jun 15 '19 08:06 SafeSoft-tlt

And better write your notification module: https://community.asterisk.org/t/interest-in-implementing-sip-push-notification/75563/17

Just do not bypass the restrictions of 255 characters as written in the example. Better change the size of the table field in the Asterisk database.

SafeSoft-tlt avatar Jun 15 '19 08:06 SafeSoft-tlt

@brianjmurrell Mind sharing your flexisip.conf? Are you using PJSIP? I'm having issues with authentication and was wondering if you were able to use MD5 auth?

driesken avatar Jul 01 '19 11:07 driesken

encode string as "username:domain:password"

ROR self.ha1 = Digest::MD5.hexdigest("#{self.sip_username}:#{domain}:#{self.password}")

PHP $ha1 = md5("$sip_username:$domain:$password")

SafeSoft-tlt avatar Jul 01 '19 11:07 SafeSoft-tlt

Yes, I'm aware on how to generate the MD5 (all my endpoints are using md5 for auth), but I don't think the MD5 is being interpreted correctly by flexisip (I'm using the userdb.conf). For some reason, it can't parse the realm and takes the IP-address of the Asterisk node by default.

driesken avatar Jul 01 '19 11:07 driesken

I use postgresql. Domain Linphone takes from account settings.

SafeSoft-tlt avatar Jul 01 '19 11:07 SafeSoft-tlt

I use postgresql. Domain Linphone takes from account settings.

Interesting. Could try that instread of the flat text file. Are you connecting by ODBC? Which parameters are you using? I'm having some trouble because of an unknown "request" parameter (latest snapshot): 2019-07-01 13:43:14:513 flexisip-error-Unsupported parameter 'request' in section [module::Authentication] at line 124. Did you mean 'count-eval-true'?

driesken avatar Jul 01 '19 11:07 driesken

ODBC is not supported in my version of Flexisip. I use SOCI.

SafeSoft-tlt avatar Jul 01 '19 11:07 SafeSoft-tlt

@driesken I don't have anything near a working flexisip configuration. I've actually given up on trying to get flexisip working as frankly, I find the documentation and examples of how to configure flexisip very lacking. They were written by somebody obviously very familiar with flexisip for people who are also familiar with flexisip, IMHO.

If any of you have working flexisip configurations, I would actually appreciate seeing a working configuration. I'm specifically looking for flexisip to be a proxy for Asterisk to linphone phones with push notification.

brianjmurrell avatar Jul 02 '19 11:07 brianjmurrell

@brianjmurrell I couldn't agree more. After struggling with flexisip.conf I've finally managed to get some basics working. flexisip.txt

I must say that I couldn't get the flexisip authentication module working. When I did some testing, I first tried the db-implementation "file". Afterwards, I tried soci as @SafeSoft-tlt suggested but that fails somewhere in the authentication process. The module does notice whether the MD5 is succesfull/wrong but the logs won't indicate what's going wrong afterwards.

I'm not sure though whether this component fits well into Asterisk. A dial within Asterisk to the contact (Linphone is closed but the contact is still present within Asterisk) immediately returns CONGESTION, so there is no time for the device to wake up. I'm also having issues with one-way audio, untill the call is paused (so a re-INVITE) is sent.

For me flexisip has some great potential but at the moment I won't consider running it in a production environment. I'm doing push within Asterisk and so far this works pretty good. The only problem (and that's where Flexisip comes in) is that Flexisip should be able to resend the INVITE untill the device has sucessfully woken.

driesken avatar Jul 02 '19 11:07 driesken

I must say that I couldn't get the flexisip authentication module working

Is your configuration (just skimmed it) (only) intended to proxy Asterisk for linphone clients so that flexisip will send push notifications to linphone clients when their extension is dialed on Asterisk?

If yes, then why do you want/need flexisip to authenticate clients? IMHO, it should just be passing that authentication through to Asterisk. IOW, flexisip shouldn't have any kind of client account database at all and just defer authentication of those client to Asterisk.

brianjmurrell avatar Jul 02 '19 12:07 brianjmurrell

I must say that I couldn't get the flexisip authentication module working

Is your configuration (just skimmed it) (only) intended to proxy Asterisk for linphone clients so that flexisip will send push notifications to linphone clients when their extension is dialed on Asterisk?

If yes, then why do you want/need flexisip to authenticate clients? IMHO, it should just be passing that authentication through to Asterisk. IOW, flexisip shouldn't have any kind of client account database at all and just defer authentication of those client to Asterisk.

That's correct, proxy only. Yes you're right! I only tried it because maybe it would be required for Flexisip to keep track of its push tokens along with each extension.

driesken avatar Jul 02 '19 12:07 driesken

Install: aptitude install bc-flexisip = 1.0.13-198 flexisip.txt

SafeSoft-tlt avatar Jul 02 '19 12:07 SafeSoft-tlt

Install: aptitude install bc-flexisip = 1.0.13-198 flexisip.txt

You don't have push enabled in your config?

driesken avatar Jul 02 '19 12:07 driesken

If you turn it on you will need to configure the field: firebase-projects-api-keys = and indicate where your Apple VoIP certificate is in the field: apple-certificate-dir =

To do this, you will need to collect your version of Linphone for Android and iPhone.

SafeSoft-tlt avatar Jul 02 '19 12:07 SafeSoft-tlt

If you turn it on you will need to configure the field: firebase-projects-api-keys = and indicate where your Apple VoIP certificate is in the field: apple-certificate-dir =

To do this, you will need to collect your version of Linphone for Android and iPhone.

I've configured the "firebase-projects-api-keys" but the push isn't requested. It works fine within Asterisk and with the flexisip_pusher though.

driesken avatar Jul 02 '19 12:07 driesken

Because in Flexisip there is an error in the latest versions. Module [module :: PushNotification] is disabled!

SafeSoft-tlt avatar Jul 02 '19 12:07 SafeSoft-tlt

You also need to run the application with the configured account, otherwise Flexisip will not find a device for push notifications. To prevent device information from being lost when rebooting Flexisip, install Redis.

SafeSoft-tlt avatar Jul 02 '19 13:07 SafeSoft-tlt

@brianjmurrell I've finally managed to get some basics working. flexisip.txt

In your config, you have:

transports=sip:*

Does that mean that you have flexisip and Asterisk on different machines?

brianjmurrell avatar Jul 02 '19 21:07 brianjmurrell

@brianjmurrell I've finally managed to get some basics working. flexisip.txt

In your config, you have:

transports=sip:*

Does that mean that you have flexisip and Asterisk on different machines?

Yes I have.

driesken avatar Jul 02 '19 21:07 driesken

Yes I have.

So that's different for me. I have them on the same machine with flexisip listening on port 5061.

Do you even get successful linphone registrations at all? The account status for me on linphone stays yellow, indicating that the registration does not complete, which is probably indicative of the fact that my Asterisk gets absolutely nothing from flexisip while linphone is apparently trying to register to flexisip.

I'd expect to see a parallel registration from flexisip to Asterisk while linphone is trying to register to flexisip.

brianjmurrell avatar Jul 02 '19 21:07 brianjmurrell

Yes I have.

So that's different for me. I have them on the same machine with flexisip listening on port 5061.

Do you even get successful linphone registrations at all? The account status for me on linphone stays yellow, indicating that the registration does not complete, which is probably indicative of the fact that my Asterisk gets absolutely nothing from flexisip while linphone is apparently trying to register to flexisip.

I'd expect to see a parallel registration from flexisip to Asterisk while linphone is trying to register to flexisip.

Yes, registration works fine. When you execute "pjsip set logger on" (or do a tcpdump), do you see registrations coming in which get an "Unauthorized" from Asterisk? I've had some issues with a wrong realm being used but that was fixed by using "reg_identity" in my linphone xml provisioning files.

driesken avatar Jul 03 '19 05:07 driesken

Yeah, I get nothing. I can see the REGISTER in the flexisip log but nothing at the Asterisk server.

What exactly in the flexisip.log is supposed to tell flexisip where to forward REGISTER requests?

Any chance you'd attach a log snippet from flexisip of your client registering to it and it registering to Asterisk so that I might see where mine is going wrong?

brianjmurrell avatar Jul 03 '19 11:07 brianjmurrell

I suppose flexisip reads this from the VIA header in the REGISTER. Have you configured linphone to register using udp or tcp? Maybe choose a non-ambigious port for flexisip instead of 5060/5061?

Sure, but I'm out of office atm so I can share those tomorrow.

driesken avatar Jul 03 '19 12:07 driesken

The Via: header from my linphone client looks like:

Via: SIP/2.0/TCP 10.75.22.32:36560;alias;branch=z9hG4bK.RQlh0cRqj;rport

so I don't see anything there that would tell flexisip where Asterisk is.

brianjmurrell avatar Jul 03 '19 12:07 brianjmurrell

Sorry, not the VIA header. That contains the device's IP address. The REGISTER is directed to the host in the IP fragment itself: 2019-04-03 09:10:57:200 flexisip-debug-Sending Request SIP message to sip:10.75.22.8:5060 REGISTER sip:pbx-mobile.example.com SIP/2.0

Also, I can see signs of ipv6 in those? You could try to disable this within Linphone and flexisip. Could you post a redacted version of your config perhaps?

driesken avatar Jul 03 '19 15:07 driesken

Hrm. I'm not even getting that any more, using a modified (for local) flexisip.conf from @SafeSoft-tlt.

I might have to see what I had back on April 03.

brianjmurrell avatar Jul 03 '19 15:07 brianjmurrell

Hrm. I'm not even getting that any more, using a modified (for local) flexisip.conf from @SafeSoft-tlt.

I might have to see what I had back on April 03.

You could try my config posted above. Mine also makes use of the ContactRouteInserter:

"The purpose of the ContactRouteInserter module is to masquerade the contact header of incoming registers that are not handled locally (think about flexisip used as a SBC gateway) in such a way that it is then possible to route back outgoing invites to the original address. It is a kind of similar mechanism as Record-Route, but for REGISTER.

driesken avatar Jul 03 '19 16:07 driesken

@driesken Ahhh, sorry. It is yours that I am using in fact. And it's quite close to what I had back on Apr. 03.

brianjmurrell avatar Jul 03 '19 16:07 brianjmurrell