Hello Kamailio community
kamailio v5.5.4
debian10
Lua Scripting Routing:
listen=tcp:127.0.0.1:5060
tcp_accept_no_cl=yes
loadmodule "xhttp.so"
loadmodule "app_lua.so"
modparam("app_lua", "load", "/etc/kamailio/kamailio.lua")
cfgengine "lua"
function ksr_xhttp_event()
KSR.set_reply_no_connect()
KSR.set_reply_close()
KSR.xhttp.xhttp_reply(404, "Not Found", "text/plain", "Not
Found")
end
curl
http://127.0.0.1:5060 -vvv
* Expire in 0 ms for 6 (transfer 0x555d93fd9fb0)
* Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x555d93fd9fb0)
* Connected to 127.0.0.1 (127.0.0.1) port 5060 (#0)
GET / HTTP/1.1
Host: 127.0.0.1:5060
User-Agent: curl/7.64.0
Accept: */*
< HTTP/1.1 404 Not Found
< Sia: SIP/2.0/TCP 127.0.0.1:54944
< Content-Type: text/plain
< Server: kamailio (5.4.4 (x86_64/linux))
< Content-Length: 9
<
* Connection #0 to host 127.0.0.1 left intact
The output of curl is OK, but have some unexpected error in kamailio.log
ERROR: <core> [core/parser/parse_fline.c:271]: parse_first_line(): parse_first_line:
bad message (offset: 16)
ERROR: <core> [core/parser/msg_parser.c:681]: parse_msg(): ERROR: parse_msg:
message=<HTTP/1.1 404 Not Found#015#012Sia: SIP/2.0/TCP
127.0.0.1:54946#015#012Content-Type: text/plain#015#012Server: kamailio (5.4.4
(x86_64/linux))#015#012Content-Length: 9#015#012#015#012Not Found>
ERROR: <core> [core/msg_translator.c:3235]: build_sip_msg_from_buf(): parsing
failed
now change to Native Scripting Routing:
listen=tcp:127.0.0.1:5060
tcp_accept_no_cl=yes
loadmodule "xhttp.so"
event_route[xhttp:request] {
set_reply_close();
set_reply_no_connect();
xhttp_reply("404", "Not Found", "text/plain", "Not
Found");
exit;
}
curl
http://127.0.0.1:5060 -vvv
everything is ok.
here is the Navite config file:
http://220.231.180.131:12296/kam/native/
here is the Lua config file:
http://220.231.180.131:12296/kam/kemi/
hanxiaofang