[OpenSIPS-Users] is this a bug? acc module setting empty string for unset fields
Kingsley Tart
kingsley at dns99.co.uk
Thu Apr 29 13:21:51 EST 2021
Hi,
This is with OpenSIPS 3.1.
I have extra DB fields defined with "extra_fields", and this was
working fine until I tried to turn on multi-leg accounting so that I
could log details of failures, eg endpoint address, SIP response etc.
I have a failure route set up to try the next endpoint, eg when I get
an INVITE:
t_on_failure("next_host");
and:
failure_route[next_host] {
# dialog flag 1 means a CANCEL has been received
if (!is_dlg_flag_set(1)) {
$avp(endpoint) = NULL;
if ($avp(endpoint)) {
t_on_failure("next_host");
acc_new_leg();
sethost($avp(endpoint));
route(numheaders_set_for_endpoint);
route(relay);
exit;
}
send_reply(503, "Service unavailable");
exit;
}
}
The problems started when I added acc_new_leg() into the failure route.
I've set this up so that the first few endpoints fail so that I can see
what is happening.
The problem is that when the BYE is received, I get the following
errors:
CRITICAL:db_mysql:wrapper_single_mysql_real_query: driver error (1366): Incorrect integer value: '' for column `opensips`.`acc`.`t_ringing` at row 1
ERROR:core:db_do_insert: error while submitting query
ERROR:acc:acc_db_request: failed to insert into acc table
The problem here is that t_ringing is an integer column (which defaults
to NULL) so it can't take a string, and OpenSIPS is trying to set the
value to an empty string.
I tried specifically setting $acc_extra(t_ringing) = NULL but this made
no difference.
I tried moving t_ringing into "leg_fields" (needed to do that anyway)
and then setting $acc_leg(t_ringing) in the script when needed, but the
same problem persisted.
These are the DB actions that OpenSIPS performs on the acc and
missed_calls tables:
Prepare insert into missed_calls (method,from_tag,to_tag,callid,sip_code,sip_reason,time,srcAddr,numFrom,numTo,numPAI,numPPI,hdrPrivacy,numRPID,hdrRPIDprivacy,hdrRPIDscreen,t_start,t_ringing,t_progress,t_answer,t_clear,dstAddr,setuptime,created ) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
Execute insert into missed_calls (method,from_tag,to_tag,callid,sip_code,sip_reason,time,srcAddr,numFrom,numTo,numPAI,numPPI,hdrPrivacy,numRPID,hdrRPIDprivacy,hdrRPIDscreen,t_start,t_ringing,t_progress,t_answer,t_clear,dstAddr,setuptime,created ) values ('INVITE','2007660754','z9hG4bK048.2ac41536.0','1619701113-752375-609080253','401','Unauthorized',TIMESTAMP'2021-04-29 13:58:33','88.151.41.21','00353*9051','01743850850','0018001231234','118118','none','003539994444',NULL,NULL,'1619701113',NULL,NULL,NULL,'1619701113','88.151.41.23',0,TIMESTAMP'2021-04-29 13:58:33')
Prepare insert into acc (method,from_tag,to_tag,callid,sip_code,sip_reason,time,srcAddr,numFrom,numTo,numPAI,numPPI,hdrPrivacy,numRPID,hdrRPIDprivacy,hdrRPIDscreen,t_start,t_ringing,t_progress,t_answer,t_clear,dstAddr,setuptime,created,duration,ms_duration ) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
Execute insert into acc (method,from_tag,to_tag,callid,sip_code,sip_reason,time,srcAddr,numFrom,numTo,numPAI,numPPI,hdrPrivacy,numRPID,hdrRPIDprivacy,hdrRPIDscreen,t_start,t_ringing,t_progress,t_answer,t_clear,dstAddr,setuptime,created,duration,ms_duration ) values ('INVITE','2007660754',NULL,'1619701113-752375-609080253','503','Service Unavailable',TIMESTAMP'2021-04-29 13:58:33','88.151.41.21','00353*9051','01743850850','0018001231234','118118','none','003539994444',NULL,NULL,'1619701113',NULL,NULL,NULL,'1619701113','88.151.41.23',0,NULL,0,0)
Query insert into acc (method,from_tag,to_tag,callid,sip_code,sip_reason,time,srcAddr,numFrom,numTo,numPAI,numPPI,hdrPrivacy,numRPID,hdrRPIDprivacy,hdrRPIDscreen,t_start,t_ringing,t_progress,t_answer,t_clear,dstAddr,setuptime,created,duration,ms_duration ) values ('INVITE','2007660754','','1619701113-752375-609080253','503','Service Unavailable','2021-04-29 13:58:33','88.151.41.21','00353*9051','01743850850','0018001231234','118118','none','003539994444','','','1619701113','','','','1619701113','88.151.41.24',0,NULL,0,0)
Is this a bug?
I would prefer any fields not set in my script to be either set as
NULL, or perhaps even better not even mentione in the query at all.
--
Cheers,
Kingsley.
More information about the Users
mailing list