Message boundary challenges are an innate part of the architecture of raw TCP services.
How does Kamailio know when a complete message has been read from the socket, with a
transport where the number of bytes available for reading is decoupled from message
delimiters?
Normally, CRLF/newline would be the expected delimiter, and I would guess that's true
of EVAPI too. If your Python script's responses aren't terminated with a newline,
I would guess that they probably need to be.
However, I haven't run into this issue because I use the netstring approach to the
boundary problem:
https://kamailio.org/docs/modules/5.8.x/modules/evapi.html#evapi.p.netstrin…
-- Alex
On Jan 8, 2025, at 12:25 pm, Sergio Charrua via
sr-users <sr-users(a)lists.kamailio.org> wrote:
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
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions --
sr-users(a)lists.kamailio.org
To unsubscribe send an email to sr-users-leave(a)lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
--
Alex Balashov
Principal Consultant
Evariste Systems LLC
Web:
https://evaristesys.com
Tel: +1-706-510-6800