How to properly add hangup reason into CDR?

Hello,

I’ve got a dialplan that includes

<snip>
same = n,Set(CHANNEL(hangup_handler_push)=update-cdr,s,1)
<snip>

[update-cdr]
exten = s,1,Set(ARRAY(first_item)=${HANGUPCAUSE_KEYS()})
same = n,Set(ARRAY(CDR(techcause_as_text))=${HANGUPCAUSE(${first_item},tech)})
same = n,Return()

From time to time (~5% of calls), it produces the following error:

[Oct  3 13:17:03] WARNING[803] res_odbc.c: SQL Execute returned an error: HY000: [ma-3.1.9][10.11.6-MariaDB-0+deb12u1]Field 'techcause_as_text' doesn't have a default value

Where does it come from ? How can I improve this ?

Best regards

I forgot to mention in my previous question, that the system I work on has two different entries in cdr_adaptive_odbc.conf for two parallel connections to two different databases.

I wonder if the message comes from this.
I’ll search in this direction.

Without knowing what actually happened in the dialplan, one can only guess that no outgoing attempt was made, and there is no hangup cause present, so it’s empty and based on the output the field can’t be empty.

Thank you for replying.

Thinking back to my original question, I omitted several details which might be important here. Here they are:

  1. I have two parallel database connections and I’m not sure of the origin of the error message (it may relate to one data or the other as both are quite different)
  2. I’m not sure how to use HANGUPCAUSE_KEYS() when you your dialplan voluntarily hangs a call up.

Let me re-phare my questions:

Let’s suppose you have 2 CDR adaptive connections.
In the first one, CDR are to be saved in table table1 and table1 has columns A and B.
For the second connection, CDR are saved in table2 which has columns B and C.
The dialplan sets values for A, B and C (with Set(CDR(A)=foo), etc …).
My understanding is Asterisk somehow queries each database to get the of the columns to be saved for each connection (so that editing a mapping like in cdr_custom.conf is not needed).
Is this correct ?
If positive, is there a way to control Asterisk’s reading ?

With the thereafter dialplan, is HANGUPCAUSE_KEYS() supposed to return anything when run in a hangup handler ?

exten = 123,1,Set(CHANNEL(hangup_handler_push)=update-cdr,s,1)
same = n,Answer()
same = n,Playback(tt-monkeys)
same = n,Hangup()

[update-cdr]
exten = s,1,Set(ARRAY(first_item)=${HANGUPCAUSE_KEYS()})
same = n,Set(ARRAY(CDR(techcause_as_text))=${HANGUPCAUSE(${first_item},tech)})
same = n,Return()

I can’t comment on the database side of things, I’m not sure how it’s that relevant either to the issue at hand either.

And in the given dialplan I would not expect any hangup cause information to be available for channels, because no channels were called.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.