Hi!
I'm wondering if there is a way for the acc-module to notify/send an event to Kamailio (so I can pick it up from the config, similar to event_route) once the acc-module has performed a write?
As an example I'm using acc and db-mysql to store acc data in MySQL, but instead of having a service polling the MySQL for new acc's written I'd like to make Kamailio send an event once an acc-row has been written. I realize this could most likely be done by using MySQL triggers "ON INSERT", but I'm wondering if there is another (reliable) way to do this directly from within Kamailio?
I haven't tested it, but I would guess that if I tried to use for example event_route[dialog:end] there could be times where the event would hit Kamailio before the acc-module have written to missed_calls?
Thanks!
/Tobias
Hello,
On 24/01/2017 12:23, Tobias wrote:
Hi!
I'm wondering if there is a way for the acc-module to notify/send an event to Kamailio (so I can pick it up from the config, similar to event_route) once the acc-module has performed a write?
As an example I'm using acc and db-mysql to store acc data in MySQL, but instead of having a service polling the MySQL for new acc's written I'd like to make Kamailio send an event once an acc-row has been written. I realize this could most likely be done by using MySQL triggers "ON INSERT", but I'm wondering if there is another (reliable) way to do this directly from within Kamailio?
I haven't tested it, but I would guess that if I tried to use for example event_route[dialog:end] there could be times where the event would hit Kamailio before the acc-module have written to missed_calls?
Do you still want the acc record to be written in the database or catch the event before storing and directing it somewhere else?
Cheers, Daniel
Hi Daniel,
I'd still like the acc record to be written, and then get notified about that writing was completed, including the mysql ID, callid and maybe something more, perhaps the whole record written? I'd like a notification for all writes, i.e. doesn't matter if it's acc.acc or acc.missed_calls, INVITEs or BYE, etc.
Kind regards,
/Tobias
________________________________ From: sr-users sr-users-bounces@lists.sip-router.org on behalf of Daniel-Constantin Mierla miconda@gmail.com Sent: Tuesday, January 24, 2017 3:02 PM To: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] Event when acc is written?
Hello,
On 24/01/2017 12:23, Tobias wrote:
Hi!
I'm wondering if there is a way for the acc-module to notify/send an event to Kamailio (so I can pick it up from the config, similar to event_route) once the acc-module has performed a write?
As an example I'm using acc and db-mysql to store acc data in MySQL, but instead of having a service polling the MySQL for new acc's written I'd like to make Kamailio send an event once an acc-row has been written. I realize this could most likely be done by using MySQL triggers "ON INSERT", but I'm wondering if there is another (reliable) way to do this directly from within Kamailio?
I haven't tested it, but I would guess that if I tried to use for example event_route[dialog:end] there could be times where the event would hit Kamailio before the acc-module have written to missed_calls?
Do you still want the acc record to be written in the database or catch the event before storing and directing it somewhere else?
Cheers, Daniel
-- Daniel-Constantin Mierla www.twitter.com/micondahttp://www.twitter.com/miconda -- www.linkedin.com/in/micondahttp://www.linkedin.com/in/miconda Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.comhttp://www.asipto.com Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.comhttp://www.kamailioworld.com
Kamailio World - Our site will be launched soonhttp://www.kamailioworld.com/ www.kamailioworld.com the 5th edition May 8-10, 2017 - Berlin, Germany. Website of the event and more details will be available very soon!
Daniel-Constantin Mierla | LinkedInhttp://www.linkedin.com/in/miconda www.linkedin.com View Daniel-Constantin Mierla's professional profile on LinkedIn. LinkedIn is the world's largest business network, helping professionals like Daniel-Constantin Mierla discover inside connections to recommended job candidates, industry experts, and business partners.
miconda (@miconda) | Twitterhttp://www.twitter.com/miconda www.twitter.com The latest Tweets from miconda (@miconda). Co-founder and leader of Kamailio SIP Server project (former OpenSER). C Dev. Open Source RTC advocate. SIP, VoIP, VoLTE and WebRTC consultancy at Asipto. Berlin, Germany
Hello,
On 24/01/2017 18:03, Tobias wrote:
Hi Daniel,
I'd still like the acc record to be written, and then get notified about that writing was completed, including the mysql ID, callid and maybe something more, perhaps the whole record written? I'd like a notification for all writes, i.e. doesn't matter if it's acc.acc or acc.missed_calls, INVITEs or BYE, etc.
the MySQL ID is specific to MySQL (and maybe few other database engines), but not involving acc at all. So you can't get that in the config right now with acc module -- for example the acc module uses the same mechanism to write the record to syslog or send it to radius, where no ID is involved.
To some extent you may be able to do it in configuration file by replacing the acc default behaviour with sqlops. The records are written by mysql when 200ok is received (which can be caught via an onreply_route) or a final negative response is handled (which can be caught via a failure_route). There you can use acc_db_request() to write the record to database and then sqlops to retrieve the ID. Just an idea by now, but it seems to be doable ...
Cheers, Daniel
Kind regards,
/Tobias
*From:* sr-users sr-users-bounces@lists.sip-router.org on behalf of Daniel-Constantin Mierla miconda@gmail.com *Sent:* Tuesday, January 24, 2017 3:02 PM *To:* Kamailio (SER) - Users Mailing List *Subject:* Re: [SR-Users] Event when acc is written?
Hello,
On 24/01/2017 12:23, Tobias wrote:
Hi!
I'm wondering if there is a way for the acc-module to notify/send an event to Kamailio (so I can pick it up from the config, similar to event_route) once the acc-module has performed a write?
As an example I'm using acc and db-mysql to store acc data in MySQL, but instead of having a service polling the MySQL for new acc's written I'd like to make Kamailio send an event once an acc-row has been written. I realize this could most likely be done by using MySQL triggers "ON INSERT", but I'm wondering if there is another (reliable) way to do this directly from within Kamailio?
I haven't tested it, but I would guess that if I tried to use for example event_route[dialog:end] there could be times where the event would hit Kamailio before the acc-module have written to missed_calls?
Do you still want the acc record to be written in the database or catch the event before storing and directing it somewhere else?
Cheers, Daniel -- Daniel-Constantin Mierla www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.com Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.com Kamailio World - Our site will be launched soon http://www.kamailioworld.com/ www.kamailioworld.com the 5th edition May 8-10, 2017 - Berlin, Germany. Website of the event and more details will be available very soon!
Daniel-Constantin Mierla | LinkedIn http://www.linkedin.com/in/miconda www.linkedin.com View Daniel-Constantin Mierla’s professional profile on LinkedIn. LinkedIn is the world's largest business network, helping professionals like Daniel-Constantin Mierla discover inside connections to recommended job candidates, industry experts, and business partners.
miconda (@miconda) | Twitter http://www.twitter.com/miconda www.twitter.com The latest Tweets from miconda (@miconda). Co-founder and leader of Kamailio SIP Server project (former OpenSER). C Dev. Open Source RTC advocate. SIP, VoIP, VoLTE and WebRTC consultancy at Asipto. Berlin, Germany
Hi Daniel,
Thanks for your reply.
Disregarding the MySQL ID, would it be possible to get the callid of the call back from the acc module once a write has been made?
Thanks,
/Tobias
________________________________ From: Daniel-Constantin Mierla miconda@gmail.com Sent: Wednesday, January 25, 2017 9:26 AM To: Tobias; Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] Event when acc is written?
Hello,
On 24/01/2017 18:03, Tobias wrote:
Hi Daniel,
I'd still like the acc record to be written, and then get notified about that writing was completed, including the mysql ID, callid and maybe something more, perhaps the whole record written? I'd like a notification for all writes, i.e. doesn't matter if it's acc.acc or acc.missed_calls, INVITEs or BYE, etc.
the MySQL ID is specific to MySQL (and maybe few other database engines), but not involving acc at all. So you can't get that in the config right now with acc module -- for example the acc module uses the same mechanism to write the record to syslog or send it to radius, where no ID is involved.
To some extent you may be able to do it in configuration file by replacing the acc default behaviour with sqlops. The records are written by mysql when 200ok is received (which can be caught via an onreply_route) or a final negative response is handled (which can be caught via a failure_route). There you can use acc_db_request() to write the record to database and then sqlops to retrieve the ID. Just an idea by now, but it seems to be doable ...
Cheers, Daniel
Kind regards,
/Tobias
________________________________ From: sr-users sr-users-bounces@lists.sip-router.orgmailto:sr-users-bounces@lists.sip-router.org on behalf of Daniel-Constantin Mierla miconda@gmail.commailto:miconda@gmail.com Sent: Tuesday, January 24, 2017 3:02 PM To: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] Event when acc is written?
Hello,
On 24/01/2017 12:23, Tobias wrote:
Hi!
I'm wondering if there is a way for the acc-module to notify/send an event to Kamailio (so I can pick it up from the config, similar to event_route) once the acc-module has performed a write?
As an example I'm using acc and db-mysql to store acc data in MySQL, but instead of having a service polling the MySQL for new acc's written I'd like to make Kamailio send an event once an acc-row has been written. I realize this could most likely be done by using MySQL triggers "ON INSERT", but I'm wondering if there is another (reliable) way to do this directly from within Kamailio?
I haven't tested it, but I would guess that if I tried to use for example event_route[dialog:end] there could be times where the event would hit Kamailio before the acc-module have written to missed_calls?
Do you still want the acc record to be written in the database or catch the event before storing and directing it somewhere else?
Cheers, Daniel
-- Daniel-Constantin Mierla www.twitter.com/micondahttp://www.twitter.com/miconda -- www.linkedin.com/in/micondahttp://www.linkedin.com/in/miconda Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.comhttp://www.asipto.com Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.comhttp://www.kamailioworld.com
Kamailio World - Our site will be launched soonhttp://www.kamailioworld.com/ www.kamailioworld.comhttp://www.kamailioworld.com the 5th edition May 8-10, 2017 - Berlin, Germany. Website of the event and more details will be available very soon!
Daniel-Constantin Mierla | LinkedInhttp://www.linkedin.com/in/miconda www.linkedin.comhttp://www.linkedin.com View Daniel-Constantin Mierla’s professional profile on LinkedIn. LinkedIn is the world's largest business network, helping professionals like Daniel-Constantin Mierla discover inside connections to recommended job candidates, industry experts, and business partners.
miconda (@miconda) | Twitterhttp://www.twitter.com/miconda www.twitter.comhttp://www.twitter.com The latest Tweets from miconda (@miconda). Co-founder and leader of Kamailio SIP Server project (former OpenSER). C Dev. Open Source RTC advocate. SIP, VoIP, VoLTE and WebRTC consultancy at Asipto. Berlin, Germany
-- Daniel-Constantin Mierla www.twitter.com/micondahttp://www.twitter.com/miconda -- www.linkedin.com/in/micondahttp://www.linkedin.com/in/miconda Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.comhttp://www.asipto.com Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.comhttp://www.kamailioworld.com
Hello,
On 25/01/2017 09:44, Tobias wrote:
Hi Daniel,
Thanks for your reply.
Disregarding the MySQL ID, would it be possible to get the callid of the call back from the acc module once a write has been made?
to my knowledge, there is no cfg event_route executed at that moment. It should not be something complex to add, but requires c coding in acc module.
Cheers, Daniel
Hi Daniel,
Thanks. Can you point me to a good example of how this is implemented in another module, perhaps I could then add it myself to acc?
/Tobias
________________________________ From: Daniel-Constantin Mierla miconda@gmail.com Sent: Wednesday, January 25, 2017 3:20 PM To: Tobias; Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] Event when acc is written?
Hello,
On 25/01/2017 09:44, Tobias wrote:
Hi Daniel,
Thanks for your reply.
Disregarding the MySQL ID, would it be possible to get the callid of the call back from the acc module once a write has been made?
to my knowledge, there is no cfg event_route executed at that moment. It should not be something complex to add, but requires c coding in acc module.
Cheers, Daniel
-- Daniel-Constantin Mierla www.twitter.com/micondahttp://www.twitter.com/miconda -- www.linkedin.com/in/micondahttp://www.linkedin.com/in/miconda Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.comhttp://www.asipto.com Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.comhttp://www.kamailioworld.com
Kamailio World - Our site will be launched soonhttp://www.kamailioworld.com/ www.kamailioworld.com the 5th edition May 8-10, 2017 - Berlin, Germany. Website of the event and more details will be available very soon!
Daniel-Constantin Mierla | LinkedInhttp://www.linkedin.com/in/miconda www.linkedin.com View Daniel-Constantin Mierla's professional profile on LinkedIn. LinkedIn is the world's largest business network, helping professionals like Daniel-Constantin Mierla discover inside connections to recommended job candidates, industry experts, and business partners.
miconda (@miconda) | Twitterhttp://www.twitter.com/miconda www.twitter.com The latest Tweets from miconda (@miconda). Co-founder and leader of Kamailio SIP Server project (former OpenSER). C Dev. Open Source RTC advocate. SIP, VoIP, VoLTE and WebRTC consultancy at Asipto. Berlin, Germany
You could check the dialog module that already has an event_route executed when a call ends.
/O
On 25 Jan 2017, at 15:45, Tobias the_fx@hotmail.com wrote:
Hi Daniel,
Thanks. Can you point me to a good example of how this is implemented in another module, perhaps I could then add it myself to acc?
/Tobias
From: Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> Sent: Wednesday, January 25, 2017 3:20 PM To: Tobias; Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] Event when acc is written?
Hello,
On 25/01/2017 09:44, Tobias wrote:
Hi Daniel,
Thanks for your reply.
Disregarding the MySQL ID, would it be possible to get the callid of the call back from the acc module once a write has been made?
to my knowledge, there is no cfg event_route executed at that moment. It should not be something complex to add, but requires c coding in acc module.
Cheers, Daniel -- Daniel-Constantin Mierla www.twitter.com/miconda http://www.twitter.com/miconda -- www.linkedin.com/in/miconda http://www.linkedin.com/in/miconda Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.com http://www.asipto.com/ Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.com http://www.kamailioworld.com/ Kamailio World - Our site will be launched soon http://www.kamailioworld.com/ www.kamailioworld.com http://www.kamailioworld.com/ the 5th edition May 8-10, 2017 - Berlin, Germany. Website of the event and more details will be available very soon!
Daniel-Constantin Mierla | LinkedIn http://www.linkedin.com/in/miconda www.linkedin.com http://www.linkedin.com/ View Daniel-Constantin Mierla’s professional profile on LinkedIn. LinkedIn is the world's largest business network, helping professionals like Daniel-Constantin Mierla discover inside connections to recommended job candidates, industry experts, and business partners.
miconda (@miconda) | Twitter http://www.twitter.com/miconda www.twitter.com http://www.twitter.com/ The latest Tweets from miconda (@miconda). Co-founder and leader of Kamailio SIP Server project (former OpenSER). C Dev. Open Source RTC advocate. SIP, VoIP, VoLTE and WebRTC consultancy at Asipto. Berlin, Germany
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org mailto:sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hello,
dispatcher module executes some event routes -- it has a wrapper function:
https://github.com/kamailio/kamailio/blob/master/src/modules/dispatcher/disp...
For acc should be simpler, because the sip request should be there, used by acc to get the attributes, so no need to make a fake one. Should be a pice of code like next one plugged in acc_onreply() function from acc module:
rt = route_lookup(&event_rt, "acc:record-stored"); if(rt < 0 || event_rt.rlist[rt] == NULL) { LM_DBG("event route does not exist"); return; } backup_rt = get_route_type(); set_route_type(REQUEST_ROUTE); init_run_actions_ctx(&ctx); run_top_route(event_rt.rlist[rt], preq, 0); set_route_type(backup_rt);
That's based on a very quick look in the code, you may need to tune a bit (and define some vars, add includes, etc.).
Cheers, Daniel
On 25/01/2017 15:45, Tobias wrote:
Hi Daniel,
Thanks. Can you point me to a good example of how this is implemented in another module, perhaps I could then add it myself to acc?
/Tobias
*From:* Daniel-Constantin Mierla miconda@gmail.com *Sent:* Wednesday, January 25, 2017 3:20 PM *To:* Tobias; Kamailio (SER) - Users Mailing List *Subject:* Re: [SR-Users] Event when acc is written?
Hello,
On 25/01/2017 09:44, Tobias wrote:
Hi Daniel,
Thanks for your reply.
Disregarding the MySQL ID, would it be possible to get the callid of the call back from the acc module once a write has been made?
to my knowledge, there is no cfg event_route executed at that moment. It should not be something complex to add, but requires c coding in acc module.
Cheers, Daniel -- Daniel-Constantin Mierla www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.com Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.com Kamailio World - Our site will be launched soon http://www.kamailioworld.com/ www.kamailioworld.com the 5th edition May 8-10, 2017 - Berlin, Germany. Website of the event and more details will be available very soon!
Daniel-Constantin Mierla | LinkedIn http://www.linkedin.com/in/miconda www.linkedin.com View Daniel-Constantin Mierla’s professional profile on LinkedIn. LinkedIn is the world's largest business network, helping professionals like Daniel-Constantin Mierla discover inside connections to recommended job candidates, industry experts, and business partners.
miconda (@miconda) | Twitter http://www.twitter.com/miconda www.twitter.com The latest Tweets from miconda (@miconda). Co-founder and leader of Kamailio SIP Server project (former OpenSER). C Dev. Open Source RTC advocate. SIP, VoIP, VoLTE and WebRTC consultancy at Asipto. Berlin, Germany
Hi,
On Wed, Jan 25, 2017 at 9:26 AM, Daniel-Constantin Mierla <miconda@gmail.com
wrote:
To some extent you may be able to do it in configuration file by replacing the acc default behaviour with sqlops. The records are written by mysql when 200ok is received (which can be caught via an onreply_route) or a final negative response is handled (which can be caught via a failure_route). There you can use acc_db_request() to write the record to database and then sqlops to retrieve the ID. Just an idea by now, but it seems to be doable ...
Be careful with own-built accounting. We did this on a system once, and you really have to make sure you account the correct reply. For instance if the call is forked by kamailio, you might get a 486 from one device and later a 200 OK from the other one. If you only take the first reply, you might end up with wrong call state.
Regards, Sebastian
Hi Sebastian,
Thanks, that's what I would like to avoid =)
/Tobias
________________________________ From: sr-users sr-users-bounces@lists.sip-router.org on behalf of Sebastian Damm damm@sipgate.de Sent: Wednesday, January 25, 2017 9:47 AM To: Daniel-Constantin Mierla; Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] Event when acc is written?
Hi,
On Wed, Jan 25, 2017 at 9:26 AM, Daniel-Constantin Mierla <miconda@gmail.commailto:miconda@gmail.com> wrote: To some extent you may be able to do it in configuration file by replacing the acc default behaviour with sqlops. The records are written by mysql when 200ok is received (which can be caught via an onreply_route) or a final negative response is handled (which can be caught via a failure_route). There you can use acc_db_request() to write the record to database and then sqlops to retrieve the ID. Just an idea by now, but it seems to be doable ...
Be careful with own-built accounting. We did this on a system once, and you really have to make sure you account the correct reply. For instance if the call is forked by kamailio, you might get a 486 from one device and later a 200 OK from the other one. If you only take the first reply, you might end up with wrong call state.
Regards, Sebastian
On 25/01/2017 09:47, Sebastian Damm wrote:
Hi,
On Wed, Jan 25, 2017 at 9:26 AM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
To some extent you may be able to do it in configuration file by replacing the acc default behaviour with sqlops. The records are written by mysql when 200ok is received (which can be caught via an onreply_route) or a final negative response is handled (which can be caught via a failure_route). There you can use acc_db_request() to write the record to database and then sqlops to retrieve the ID. Just an idea by now, but it seems to be doable ...
Be careful with own-built accounting. We did this on a system once, and you really have to make sure you account the correct reply. For instance if the call is forked by kamailio, you might get a 486 from one device and later a 200 OK from the other one. If you only take the first reply, you might end up with wrong call state.
That's why the recommended way above for negative responses was to use failure_route, not onreply_route like for 200ok.
Cheers, Daniel