BelledonneCommunications / flexisip

Linphone.org mirror for flexisip (git://git.linphone.org/flexisip.git)
http://flexisip.org
GNU Affero General Public License v3.0
140 stars 68 forks source link

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

Open brianjmurrell opened 5 years ago

brianjmurrell commented 5 years ago

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 commented 5 years ago

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.

SafeSoft-tlt commented 5 years ago

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 commented 5 years ago

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.

driesken commented 5 years ago

@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?

SafeSoft-tlt commented 5 years ago

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")

driesken commented 5 years ago

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.

SafeSoft-tlt commented 5 years ago

I use postgresql. Domain Linphone takes from account settings.

driesken commented 5 years ago

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'?

SafeSoft-tlt commented 5 years ago

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

brianjmurrell commented 5 years ago

@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.

driesken commented 5 years ago

@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.

brianjmurrell commented 5 years ago

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.

driesken commented 5 years ago

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.

SafeSoft-tlt commented 5 years ago

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

driesken commented 5 years ago

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

You don't have push enabled in your config?

SafeSoft-tlt commented 5 years ago

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.

driesken commented 5 years ago

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.

SafeSoft-tlt commented 5 years ago

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

SafeSoft-tlt commented 5 years ago

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.

brianjmurrell commented 5 years ago

@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?

driesken commented 5 years ago

@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.

brianjmurrell commented 5 years ago

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.

driesken commented 5 years ago

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.

brianjmurrell commented 5 years ago

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?

driesken commented 5 years ago

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.

brianjmurrell commented 5 years ago

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.

driesken commented 5 years ago

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?

brianjmurrell commented 5 years ago

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.

driesken commented 5 years ago

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.

brianjmurrell commented 5 years ago

@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 commented 5 years ago

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

@SafeSoft-tlt Can you expand on the above? Not that I think it's relevant to my issues, but would be good to know what you think is broken in any case.

SafeSoft-tlt commented 5 years ago

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

@SafeSoft-tlt Can you expand on the above? Not that I think it's relevant to my issues, but would be good to know what you think is broken in any case.

I had a working version of Flexisip installed in March of this year. In June, I installed a new version of Flexisip with the same flexisip.conf file and push notifications stopped working for me. I found the working March version: bc-flexisip = 1.0.13-198

brianjmurrell commented 5 years ago

@SafeSoft-tlt Have you filed a ticket about it?

SafeSoft-tlt commented 5 years ago

Every week they publish new versions, half of them with errors. How can I help them?

brianjmurrell commented 5 years ago

Filing tickets with your findings so that they know.

driesken commented 5 years ago

Could this be fixed a few minutes ago? I'll have to wait for the rpm to appear in the repo.

SafeSoft-tlt commented 4 years ago

How did you manage to solve the problem - 32 seconds? https://github.com/BelledonneCommunications/linphone-android/issues/150#issuecomment-440966225

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.

https://github.com/BelledonneCommunications/linphone-android/issues/150#issuecomment-440966225

brianjmurrell commented 4 years ago

I have a configuration which accepts the REGISTER (on port 5061) from my linphone instance but it then proceeds to forward that registration to itself and not the Asterisk on the same machine on port 5060.

Given that I have told linphone to register to my PBX on port 5061 where flexisip is how is flexisip supposed to know that it's proxying for the Asterisk on the same machine on port 5060? What is my missing link to get flexisip to forward to Asterisk on 5060 and not itself on 5061?

driesken commented 4 years ago

How did you manage to solve the problem - 32 seconds? BelledonneCommunications/linphone-android#150 (comment)

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.

BelledonneCommunications/linphone-android#150 (comment)

I didn't. The problem with my setup is that there is only one-way audio after call setup. When I pause and resume the call, audio in both ways is working. Also can't seem to figure out why there is no attempt at push.

EDIT: disabled the transcoder and seems to be working. I'm not experiencing the 32 sec issue. Mostly this is due to a missing OK. I haven't figured out why there aren't any push attempts.

brianjmurrell commented 4 years ago

I also have no push attempts from my configuration.

https://lists.nongnu.org/archive/html/flexisip-developers/2019-07/msg00008.html

SafeSoft-tlt commented 4 years ago

How did you manage to solve the problem - 32 seconds? BelledonneCommunications/linphone-android#150 (comment)

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.

BelledonneCommunications/linphone-android#150 (comment)

I didn't. The problem with my setup is that there is only one-way audio after call setup. When I pause and resume the call, audio in both ways is working. Also can't seem to figure out why there is no attempt at push.

EDIT: disabled the transcoder and seems to be working. I'm not experiencing the 32 sec issue. Mostly this is due to a missing OK. I haven't figured out why there aren't any push attempts.

I have a push notification for Android. But with "db-implementation = redis" it works incorrectly. After restarting flexisip, did you launch your Android app?

SafeSoft-tlt commented 4 years ago

I have a configuration which accepts the REGISTER (on port 5061) from my linphone instance but it then proceeds to forward that registration to itself and not the Asterisk on the same machine on port 5060.

Given that I have told linphone to register to my PBX on port 5061 where flexisip is how is flexisip supposed to know that it's proxying for the Asterisk on the same machine on port 5060? What is my missing link to get flexisip to forward to Asterisk on 5060 and not itself on 5061?

[global] transports=sips:*

[module::Forward] route=sip::5060

SafeSoft-tlt commented 4 years ago

[global] transports=sips:*

[module::Forward] route=sip:[asterisk IP]:5060

SafeSoft-tlt commented 4 years ago

Settings need to be made in the Proxy field of the application account. Proxy needs to be enabled.

I also have no push attempts from my configuration.

https://lists.nongnu.org/archive/html/flexisip-developers/2019-07/msg00008.html

Filter remove: [module::PushNotification] enabled=true filter= timeout=0


Settings need to be made in the Proxy field of the application account. Proxy needs to be enabled.

brianjmurrell commented 4 years ago

I have all of the above and still no push notifications.

driesken commented 4 years ago

Anyone who has made progress in getting push to work? If I run a test with flexisip_pusher, it works fine.

brianjmurrell commented 4 years ago

Anyone who has made progress in getting push to work?

Nope.

If I run a test with flexisip_pusher, it works fine.

Indeed. I can push successfully all I want to linphone-android. It's getting flexisip to actually send the push that is the problem.

And there appears to be zero help or advise from the developers either here or on the flexisip-developers list. Unfortunately.

I've pretty much given up on flexisip and am pushing from Asterisk directly.

dipenpatel235 commented 4 years ago

flexisip_pusher, it works fine. but not working flexisip push on call.

Below is mine flexisip version

[root@sip ~]# flexisip -v flexisip version: 2.0.0-beta-13-g521ea70 sofia-sip version 1.13.41bc Compiled with:

Sterlin11 commented 11 months ago

@brianjmurrell I am facing issue with the integration of Asterisk as backend server and flexisip as sip proxy, if possible could you please share the flexisip and Asterisk (pjsip.conf )file? ,so that I will compare with my configuration . Thanks in advance

brianjmurrell commented 11 months ago

I was never able to get Flexisip to work as a proxy. The configuration is too cryptic and/or undocumented (sufficiently).