Hi all!
I have implemented evapi module on Kamailio 5.8.4, calling a python script.
Python script is listening to a socket. It receives messages (JSON) from
Kamailio, makes an HTTP request somewhere, and sends the response back to
Kamailio.
The Python script is working fine: it connects to Kamailio, sends HTTP
requests, and forwards a response back to Kamailio: I have confirmed using
TCPDump that, in fact, the data is received and forwarded back.
However, despite showing messages that the Python client script is
correctly connected to Kamailio, the event_route[evapi:message-received] is
never executed.
Probably there is some detail that I am missing, but the docs and online
info for evapi are very rare, and they all show very similar configuration.
And as I wrote, I have confirmed using TCPDump that the data is received
from Python client script to Kamailio node.
What am I missing?
This is my Kamailio cfg:
[loads modules]
[sets modparams]
modparam("evapi","bind_addr","10.20.20.1:8888")
debug=2
children=16
log_facility=LOG_LOCAL0
log_prefix="{$mt $hdr(CSeq) $ci} "
disable_sctp = yes
force_rport = yes
rundir="/tmp"
request_route {
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
t_relay();
}
exit;
}
if(is_method("OPTIONS")){
sl_reply("200", "OK");
exit;
}
if(is_method("CANCEL")){
sl_reply("200","OK");
sl_reply("487","Request Terminated");
exit;
}
route(TOEVAPI);
exit;
}
event_route[evapi:connection-new] {
xlog("LINFO","new connection from
[$evapi(srcaddr):$evapi(srcport)]\n");
if($evapi(srcaddr)!="10.20.0.1") {
evapi_close();
exit;
}
}
event_route[evapi:connection-closed] {
xlog("LINFO","connection closed by
$evapi(srcaddr):$evapi(srcport)\n");
}
event_route[evapi:message-received] {
xlog("LINFO","received [$evapi(msg)] from
$evapi(srcaddr):$evapi(srcport)\n");
jansson_get("t-index", "$evapi(msg)",
"$var(t-index)");
jansson_get("t-label", "$evapi(msg)",
"$var(t-label)");
$var(evmsg) = $evapi(msg);
xlog("L_INFO", "preparing to resume transaction for processing:
$var(tindex) / $var(tlabel)\n");
t_continue("$var(tindex)", "$var(tlabel)",
"EVAPIRESPONSE");
}
route[EVAPIRESPONSE] {
xlog("L_INFO", "resumed transaction for processing: $T(id_index) /
$T(id_label)\n");
[do stuff]
}
route[TOEVAPI]{
xlog("L_INFO", "suspended transaction: $T(id_index) /
$T(id_label)\n");
evapi_async_relay( [some JSON string] );
exit;
}
Thanks in advance!
Atenciosamente / Kind Regards / Cordialement / Un saludo,
*Sérgio Charrua*