Re: [SR-Users] Call limit through shared database
Hello Henning, Ok I think I was wrong when I assumed the mysql would do the dialog profile syncing somehow during kamailio reboot but instead the DMQ is actually doing it like you posted earlier. I traced with wireshark and noticed that after kam2 rebooted itself and became responsive again, kam1 node informed the kam2 with the active dialog profiles via dmq. Thank you. --Olli pe 4. lokak. 2019 klo 15.33 Henning Westerholt (h...@skalatan.de) kirjoitti: > > Hello Olli, > > > > the profile information should be also synchronized with DMQ – but not sure > if they are also synchronized during startup. If kam2 reboots it should get > the dialog information from kam1 after it has started. > > > > Have you tried if its works already? > > > > Cheers, > > > > Henning > > > > -- > > Henning Westerholt - https://skalatan.de/blog/ > > Kamailio services - https://skalatan.de/services > > > > From: Olli Attila > Sent: Friday, October 4, 2019 5:54 AM > To: Henning Westerholt > Cc: Kamailio (SER) - Users Mailing List > Subject: Re: [SR-Users] Call limit through shared database > > > > Hello Henning, > > > > I tried the dialog profile sharing with dmq modules and now the > syncing works between the two kam nodes. Thank you! > > > > Is there a way to keep the dialog profiles persistent (load from db if kam > restarts)? I was thinking a scenario where kam1 has already the call limit > maxed out and kam2 suddenly reboots and after reboot, kam2 should be aware of > dialogs on kam1 to be able to limit calls again correctly. > > > > Cheers, > > Olli -- "Logic is the art of going wrong with confidence." ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
Hello, I had the following enabled in db_mode param and now it is actually working: *1 - REALTIME* - any dialog information changes will be reflected into the database immediately. Restarting either of the kam1 or kam2 proxies "on the fly" will result in retrieving dialog profiles correctly from database. Cheers, Olli ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
Hello Olli, the profile information should be also synchronized with DMQ – but not sure if they are also synchronized during startup. If kam2 reboots it should get the dialog information from kam1 after it has started. Have you tried if its works already? Cheers, Henning -- Henning Westerholt - https://skalatan.de/blog/ Kamailio services - https://skalatan.de/services From: Olli Attila Sent: Friday, October 4, 2019 5:54 AM To: Henning Westerholt Cc: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] Call limit through shared database Hello Henning, I tried the dialog profile sharing with dmq modules and now the syncing works between the two kam nodes. Thank you! Is there a way to keep the dialog profiles persistent (load from db if kam restarts)? I was thinking a scenario where kam1 has already the call limit maxed out and kam2 suddenly reboots and after reboot, kam2 should be aware of dialogs on kam1 to be able to limit calls again correctly. Cheers, Olli ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
Hi Olli, if I have interpreted the question and the situation in which you are correctly, the way to persist a dialog in DB is to use the db_mode param https://kamailio.org/docs/modules/5.2.x/modules/dialog.html#dialog.p.db_mode you have 4 possibilities to persist that data in DB - *0 - NO_DB* - the memory content is not flushed into DB; - *1 - REALTIME* - any dialog information changes will be reflected into the database immediately. - *2 - DELAYED* - the dialog information changes will be flushed into DB periodically, based on a timer routine. - *3 - SHUTDOWN* - the dialog information will be flushed into DB only at shutdown - no runtime updates. Cheers, Giovanni -- Giovanni Tommasini | evosip web: https://evosip.cloud Il giorno ven 4 ott 2019 alle ore 08:31 Olli Attila ha scritto: > Hello Henning, > > I tried the dialog profile sharing with dmq modules and now the > syncing works between the two kam nodes. Thank you! > > Is there a way to keep the dialog profiles persistent (load from db if kam > restarts)? I was thinking a scenario where kam1 has already the call limit > maxed out and kam2 suddenly reboots and after reboot, kam2 should be aware > of dialogs on kam1 to be able to limit calls again correctly. > > Cheers, > Olli > ___ > Kamailio (SER) - Users Mailing List > sr-users@lists.kamailio.org > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
Hello Henning, I tried the dialog profile sharing with dmq modules and now the syncing works between the two kam nodes. Thank you! Is there a way to keep the dialog profiles persistent (load from db if kam restarts)? I was thinking a scenario where kam1 has already the call limit maxed out and kam2 suddenly reboots and after reboot, kam2 should be aware of dialogs on kam1 to be able to limit calls again correctly. Cheers, Olli ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
This is great news!! I will repeat the tests that failed for me just to be sure, but from reading your comments it seems promising!! Thanks for pointing me to it. Joel. On Tue, Oct 1, 2019 at 08:15 Henning Westerholt wrote: > Hi Joel, > > > > Thank you, I was reading it yesterday. See this issue > https://github.com/kamailio/kamailio/issues/2080#issue-499544483 – in my > tests the proxies will expire the dialogs even after a restart. I just > tested it again even restarting both proxies a few times. > > > > Cheers, > > > > Henning > > > > -- > > Henning Westerholt - https://skalatan.de/blog/ > > Kamailio services - https://skalatan.de/services > > > > *From:* sr-users *On Behalf Of *Joel > Serrano > *Sent:* Tuesday, October 1, 2019 4:35 PM > *To:* Kamailio (SER) - Users Mailing List ; > mico...@gmail.com > *Subject:* Re: [SR-Users] Call limit through shared database > > > > Found it: > > > > https://github.com/kamailio/kamailio/issues/1591#issuecomment-409205552 > > > > On Tue, Oct 1, 2019 at 07:15 Joel Serrano wrote: > > Just a note, I would suggest to use htable+dmq to do such limits, > dialog+dmq has some issues when handling dialog expiration when a node for > whatever reason is restarted.. (search GH issues and you will find one with > a long thread where Charles explains the reasons: TL;DR: You could end up > having inconsistent dialog information with dialog+dmq) > > > > Hope it helps! > > Joel. > > > > On Tue, Oct 1, 2019 at 01:02 Daniel-Constantin Mierla > wrote: > > > On 30.09.19 14:55, Daniel Tryba wrote: > > On Sun, Sep 29, 2019 at 11:03:47AM +0300, Olli Attila wrote: > >> modparam("dialog", "profiles_with_value", "concurrent_calls") > >> modparam("dialog", "dlg_flag", 4) > >> modparam("dialog", "db_url", DBURL) > >> modparam("dialog", "db_mode", 1) > > > > Have you tested with a lower value of > > > https://kamailio.org/docs/modules/5.1.x/modules/dialog.html#dialog.p.update_period > > > The update_period should have no impact when db_mode=1 -- in this case > the records are written to database immediately. I think update_period > is intended only for db_mode=2. > > Cheers, > Daniel > > > > I have it set to 5, but for some reason I'm not using get_profile_size > > > > For inbound: > > $var(maxchannels) = 0; > > sql_xquery("ca", "select count(id) as c from dialog where xdata like > '%maxchannels%$rU%' and timeout>unix_timestamp()", "ra"); > > $var(maxchannels)=$xavp(ra=>c); > > sql_result_free("ra"); > > > > For outbound: > > sql_xquery("ca", "select count(id) as c from dialog where xdata like > '%maxchannels%$au%' and timeout>unix_timestamp()", "ra"); > > $var(maxchannels)=$xavp(ra=>c); > > sql_result_free("ra"); > > > > Pasting the code here I see this isn't that secure since a user foo also > > gets the number of calls for foobar counted against him! Off to put a " > > before/after the username. > > > > > > ___ > > Kamailio (SER) - Users Mailing List > > sr-users@lists.kamailio.org > > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > > -- > Daniel-Constantin Mierla -- www.asipto.com > www.twitter.com/miconda -- www.linkedin.com/in/miconda > Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- > https://asipto.com/u/kat > > > ___ > Kamailio (SER) - Users Mailing List > sr-users@lists.kamailio.org > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > > ___ > Kamailio (SER) - Users Mailing List > sr-users@lists.kamailio.org > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
Hi Joel, Thank you, I was reading it yesterday. See this issue https://github.com/kamailio/kamailio/issues/2080#issue-499544483 – in my tests the proxies will expire the dialogs even after a restart. I just tested it again even restarting both proxies a few times. Cheers, Henning -- Henning Westerholt - https://skalatan.de/blog/ Kamailio services - https://skalatan.de/services From: sr-users On Behalf Of Joel Serrano Sent: Tuesday, October 1, 2019 4:35 PM To: Kamailio (SER) - Users Mailing List ; mico...@gmail.com Subject: Re: [SR-Users] Call limit through shared database Found it: https://github.com/kamailio/kamailio/issues/1591#issuecomment-409205552 On Tue, Oct 1, 2019 at 07:15 Joel Serrano mailto:j...@textplus.com>> wrote: Just a note, I would suggest to use htable+dmq to do such limits, dialog+dmq has some issues when handling dialog expiration when a node for whatever reason is restarted.. (search GH issues and you will find one with a long thread where Charles explains the reasons: TL;DR: You could end up having inconsistent dialog information with dialog+dmq) Hope it helps! Joel. On Tue, Oct 1, 2019 at 01:02 Daniel-Constantin Mierla mailto:mico...@gmail.com>> wrote: On 30.09.19 14:55, Daniel Tryba wrote: > On Sun, Sep 29, 2019 at 11:03:47AM +0300, Olli Attila wrote: >> modparam("dialog", "profiles_with_value", "concurrent_calls") >> modparam("dialog", "dlg_flag", 4) >> modparam("dialog", "db_url", DBURL) >> modparam("dialog", "db_mode", 1) > > Have you tested with a lower value of > https://kamailio.org/docs/modules/5.1.x/modules/dialog.html#dialog.p.update_period The update_period should have no impact when db_mode=1 -- in this case the records are written to database immediately. I think update_period is intended only for db_mode=2. Cheers, Daniel > I have it set to 5, but for some reason I'm not using get_profile_size > > For inbound: > $var(maxchannels) = 0; > sql_xquery("ca", "select count(id) as c from dialog where xdata like > '%maxchannels%$rU%' and timeout>unix_timestamp()", "ra"); > $var(maxchannels)=$xavp(ra=>c); > sql_result_free("ra"); > > For outbound: > sql_xquery("ca", "select count(id) as c from dialog where xdata like > '%maxchannels%$au%' and timeout>unix_timestamp()", "ra"); > $var(maxchannels)=$xavp(ra=>c); > sql_result_free("ra"); > > Pasting the code here I see this isn't that secure since a user foo also > gets the number of calls for foobar counted against him! Off to put a " > before/after the username. > > > ___ > Kamailio (SER) - Users Mailing List > sr-users@lists.kamailio.org<mailto:sr-users@lists.kamailio.org> > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users -- Daniel-Constantin Mierla -- www.asipto.com<http://www.asipto.com> www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda> Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- https://asipto.com/u/kat ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org<mailto:sr-users@lists.kamailio.org> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
Hello Joel, I did some research yesterday for a customer, and only found open tickets related to the dialog statistics issue (#1692). The module README also stats that the DMQ will synchronize profiles. If there are some issues related to dialog inconsistencies, then they should (preferable) be fixed or properly documented in the module. To which ticket are you referring to on github? Cheers, Henning -- Henning Westerholt - https://skalatan.de/blog/ Kamailio services - https://skalatan.de/services From: sr-users On Behalf Of Joel Serrano Sent: Tuesday, October 1, 2019 4:15 PM To: Kamailio (SER) - Users Mailing List ; mico...@gmail.com Subject: Re: [SR-Users] Call limit through shared database Just a note, I would suggest to use htable+dmq to do such limits, dialog+dmq has some issues when handling dialog expiration when a node for whatever reason is restarted.. (search GH issues and you will find one with a long thread where Charles explains the reasons: TL;DR: You could end up having inconsistent dialog information with dialog+dmq) Hope it helps! Joel. On Tue, Oct 1, 2019 at 01:02 Daniel-Constantin Mierla mailto:mico...@gmail.com>> wrote: On 30.09.19 14:55, Daniel Tryba wrote: > On Sun, Sep 29, 2019 at 11:03:47AM +0300, Olli Attila wrote: >> modparam("dialog", "profiles_with_value", "concurrent_calls") >> modparam("dialog", "dlg_flag", 4) >> modparam("dialog", "db_url", DBURL) >> modparam("dialog", "db_mode", 1) > > Have you tested with a lower value of > https://kamailio.org/docs/modules/5.1.x/modules/dialog.html#dialog.p.update_period The update_period should have no impact when db_mode=1 -- in this case the records are written to database immediately. I think update_period is intended only for db_mode=2. Cheers, Daniel > I have it set to 5, but for some reason I'm not using get_profile_size > > For inbound: > $var(maxchannels) = 0; > sql_xquery("ca", "select count(id) as c from dialog where xdata like > '%maxchannels%$rU%' and timeout>unix_timestamp()", "ra"); > $var(maxchannels)=$xavp(ra=>c); > sql_result_free("ra"); > > For outbound: > sql_xquery("ca", "select count(id) as c from dialog where xdata like > '%maxchannels%$au%' and timeout>unix_timestamp()", "ra"); > $var(maxchannels)=$xavp(ra=>c); > sql_result_free("ra"); > > Pasting the code here I see this isn't that secure since a user foo also > gets the number of calls for foobar counted against him! Off to put a " > before/after the username. > > > ___ > Kamailio (SER) - Users Mailing List > sr-users@lists.kamailio.org<mailto:sr-users@lists.kamailio.org> > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users -- Daniel-Constantin Mierla -- www.asipto.com<http://www.asipto.com> www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda> Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- https://asipto.com/u/kat ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org<mailto:sr-users@lists.kamailio.org> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
Found it: https://github.com/kamailio/kamailio/issues/1591#issuecomment-409205552 On Tue, Oct 1, 2019 at 07:15 Joel Serrano wrote: > Just a note, I would suggest to use htable+dmq to do such limits, > dialog+dmq has some issues when handling dialog expiration when a node for > whatever reason is restarted.. (search GH issues and you will find one with > a long thread where Charles explains the reasons: TL;DR: You could end up > having inconsistent dialog information with dialog+dmq) > > Hope it helps! > Joel. > > On Tue, Oct 1, 2019 at 01:02 Daniel-Constantin Mierla > wrote: > >> >> On 30.09.19 14:55, Daniel Tryba wrote: >> > On Sun, Sep 29, 2019 at 11:03:47AM +0300, Olli Attila wrote: >> >> modparam("dialog", "profiles_with_value", "concurrent_calls") >> >> modparam("dialog", "dlg_flag", 4) >> >> modparam("dialog", "db_url", DBURL) >> >> modparam("dialog", "db_mode", 1) >> > >> > Have you tested with a lower value of >> > >> https://kamailio.org/docs/modules/5.1.x/modules/dialog.html#dialog.p.update_period >> >> >> The update_period should have no impact when db_mode=1 -- in this case >> the records are written to database immediately. I think update_period >> is intended only for db_mode=2. >> >> Cheers, >> Daniel >> >> >> > I have it set to 5, but for some reason I'm not using get_profile_size >> > >> > For inbound: >> > $var(maxchannels) = 0; >> > sql_xquery("ca", "select count(id) as c from dialog where xdata like >> '%maxchannels%$rU%' and timeout>unix_timestamp()", "ra"); >> > $var(maxchannels)=$xavp(ra=>c); >> > sql_result_free("ra"); >> > >> > For outbound: >> > sql_xquery("ca", "select count(id) as c from dialog where xdata like >> '%maxchannels%$au%' and timeout>unix_timestamp()", "ra"); >> > $var(maxchannels)=$xavp(ra=>c); >> > sql_result_free("ra"); >> > >> > Pasting the code here I see this isn't that secure since a user foo also >> > gets the number of calls for foobar counted against him! Off to put a " >> > before/after the username. >> > >> > >> > ___ >> > Kamailio (SER) - Users Mailing List >> > sr-users@lists.kamailio.org >> > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users >> >> -- >> Daniel-Constantin Mierla -- www.asipto.com >> www.twitter.com/miconda -- www.linkedin.com/in/miconda >> Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- >> https://asipto.com/u/kat >> >> >> ___ >> Kamailio (SER) - Users Mailing List >> sr-users@lists.kamailio.org >> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users >> > ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
Just a note, I would suggest to use htable+dmq to do such limits, dialog+dmq has some issues when handling dialog expiration when a node for whatever reason is restarted.. (search GH issues and you will find one with a long thread where Charles explains the reasons: TL;DR: You could end up having inconsistent dialog information with dialog+dmq) Hope it helps! Joel. On Tue, Oct 1, 2019 at 01:02 Daniel-Constantin Mierla wrote: > > On 30.09.19 14:55, Daniel Tryba wrote: > > On Sun, Sep 29, 2019 at 11:03:47AM +0300, Olli Attila wrote: > >> modparam("dialog", "profiles_with_value", "concurrent_calls") > >> modparam("dialog", "dlg_flag", 4) > >> modparam("dialog", "db_url", DBURL) > >> modparam("dialog", "db_mode", 1) > > > > Have you tested with a lower value of > > > https://kamailio.org/docs/modules/5.1.x/modules/dialog.html#dialog.p.update_period > > > The update_period should have no impact when db_mode=1 -- in this case > the records are written to database immediately. I think update_period > is intended only for db_mode=2. > > Cheers, > Daniel > > > > I have it set to 5, but for some reason I'm not using get_profile_size > > > > For inbound: > > $var(maxchannels) = 0; > > sql_xquery("ca", "select count(id) as c from dialog where xdata like > '%maxchannels%$rU%' and timeout>unix_timestamp()", "ra"); > > $var(maxchannels)=$xavp(ra=>c); > > sql_result_free("ra"); > > > > For outbound: > > sql_xquery("ca", "select count(id) as c from dialog where xdata like > '%maxchannels%$au%' and timeout>unix_timestamp()", "ra"); > > $var(maxchannels)=$xavp(ra=>c); > > sql_result_free("ra"); > > > > Pasting the code here I see this isn't that secure since a user foo also > > gets the number of calls for foobar counted against him! Off to put a " > > before/after the username. > > > > > > ___ > > Kamailio (SER) - Users Mailing List > > sr-users@lists.kamailio.org > > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > > -- > Daniel-Constantin Mierla -- www.asipto.com > www.twitter.com/miconda -- www.linkedin.com/in/miconda > Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- > https://asipto.com/u/kat > > > ___ > Kamailio (SER) - Users Mailing List > sr-users@lists.kamailio.org > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
On 30.09.19 14:55, Daniel Tryba wrote: > On Sun, Sep 29, 2019 at 11:03:47AM +0300, Olli Attila wrote: >> modparam("dialog", "profiles_with_value", "concurrent_calls") >> modparam("dialog", "dlg_flag", 4) >> modparam("dialog", "db_url", DBURL) >> modparam("dialog", "db_mode", 1) > > Have you tested with a lower value of > https://kamailio.org/docs/modules/5.1.x/modules/dialog.html#dialog.p.update_period The update_period should have no impact when db_mode=1 -- in this case the records are written to database immediately. I think update_period is intended only for db_mode=2. Cheers, Daniel > I have it set to 5, but for some reason I'm not using get_profile_size > > For inbound: > $var(maxchannels) = 0; > sql_xquery("ca", "select count(id) as c from dialog where xdata like > '%maxchannels%$rU%' and timeout>unix_timestamp()", "ra"); > $var(maxchannels)=$xavp(ra=>c); > sql_result_free("ra"); > > For outbound: > sql_xquery("ca", "select count(id) as c from dialog where xdata like > '%maxchannels%$au%' and timeout>unix_timestamp()", "ra"); > $var(maxchannels)=$xavp(ra=>c); > sql_result_free("ra"); > > Pasting the code here I see this isn't that secure since a user foo also > gets the number of calls for foobar counted against him! Off to put a " > before/after the username. > > > ___ > Kamailio (SER) - Users Mailing List > sr-users@lists.kamailio.org > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users -- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- https://asipto.com/u/kat ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
Hello Olli, you can synchronize dialog profile information between Kamailio servers with the DMQ replication mechanism. You basically load and configure the DMQ module and activate it also in the dialog module. Cheers, Henning -- Henning Westerholt - https://skalatan.de/blog/ Kamailio services - https://skalatan.de/services From: sr-users On Behalf Of Olli Attila Sent: Sunday, September 29, 2019 10:04 AM To: Kamailio (SER) - Users Mailing List Subject: [SR-Users] Call limit through shared database Hello, I have 2 kam instances using one shared database and both kam servers running the same routing logic code. Kamailio servers are configured to use the same database as dialog backend. I am limiting the concurrent dialogs in the following way but it seems that kamailio is using its own memory to read profile size rather than the db. Second kam is not aware of the dialog profiles that the first kam wrote to the shared db. Is there a way to get multiple kam instances to read profile size from the same database when calling the get_profile_size function? modparam("dialog", "profiles_with_value", "concurrent_calls") modparam("dialog", "dlg_flag", 4) modparam("dialog", "db_url", DBURL) modparam("dialog", "db_mode", 1) route[LIMIT_CALLS] { if (!dlg_isflagset("1")) { # $td – gateways, $fu - user if (get_profile_size("concurrent_calls", "$fu", "$avp(calls)")) { if ($avp(calls) >= 3) { xlog("L_INFO", "Concurrent calls $fu at limit"); send_reply("503", "Calls limit reached"); exit; } else { dlg_manage(); dlg_setflag("1"); set_dlg_profile("concurrent_calls", "$fu"); } } } } Cheers, Olli ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Call limit through shared database
On Sun, Sep 29, 2019 at 11:03:47AM +0300, Olli Attila wrote: > modparam("dialog", "profiles_with_value", "concurrent_calls") > modparam("dialog", "dlg_flag", 4) > modparam("dialog", "db_url", DBURL) > modparam("dialog", "db_mode", 1) Have you tested with a lower value of https://kamailio.org/docs/modules/5.1.x/modules/dialog.html#dialog.p.update_period I have it set to 5, but for some reason I'm not using get_profile_size For inbound: $var(maxchannels) = 0; sql_xquery("ca", "select count(id) as c from dialog where xdata like '%maxchannels%$rU%' and timeout>unix_timestamp()", "ra"); $var(maxchannels)=$xavp(ra=>c); sql_result_free("ra"); For outbound: sql_xquery("ca", "select count(id) as c from dialog where xdata like '%maxchannels%$au%' and timeout>unix_timestamp()", "ra"); $var(maxchannels)=$xavp(ra=>c); sql_result_free("ra"); Pasting the code here I see this isn't that secure since a user foo also gets the number of calls for foobar counted against him! Off to put a " before/after the username. ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users