[SR-Users] Communicate with Kamailio through external application

Grant Bagdasarian GB at cm.nl
Fri Sep 27 14:18:48 CEST 2013


Hello,

The kamctl fifo ds_reload command works when I use it in putty.
The kamcmd dispatcher.reload command does NOT work.

Gives me the following error:
root at proxy01:~# kamcmd dispatcher.reload
ERROR: connect_unix_sock: connect(/tmp/kamailio_ctl): Connection refused [111]

http://192.168.1.10/http_rpc/dispatcher/dispatcher.reload?arg=dispatcher.reload

10(10232) ERROR: dispatcher [dispatch.c:725]: ds_load_db(): invalid DB handler
....
HTTP/1.1 500 Reload Failed
Via: SIP/2.0/TCP 192.168.1.11:51065
Content-Type: text/html
Server: kamailio (4.0.2 (x86_64/linux))
Content-Length: 2095

From: sr-users-bounces at lists.sip-router.org [mailto:sr-users-bounces at lists.sip-router.org] On Behalf Of Charles Chance
Sent: Friday, September 27, 2013 2:10 PM
To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] Communicate with Kamailio through external application

Hi,

I think you are mixing up the MI and RPC commands.

Try:

kamctl fifo ds_reload

or

kamcmd dispatcher.reload

(note the difference between kamctl and kamcmd)

Regards,

Charles


On 27 September 2013 12:57, Grant Bagdasarian <GB at cm.nl<mailto:GB at cm.nl>> wrote:
What kind of DB handler do I need for the dispatcher module?

When executing the dispatcher.reload command I'm receiving the following error:
8(10201) ERROR: dispatcher [dispatch.c:725]: ds_load_db(): invalid DB handler

root at proxy01:~# kamctl dispatcher reload
ERROR: This command requires a database engine - none was loaded

My Dispatcher table is loaded using db_unixodbc, because we are using MSSQL.

loadmodule "mi_fifo.so"
loadmodule "kex.so"
loadmodule "corex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "textopsx.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "db_unixodbc.so"
loadmodule "sqlops.so"
loadmodule "dispatcher.so"
loadmodule "siptrace.so"
loadmodule "avp.so"
loadmodule "cfgutils.so"
loadmodule "xhttp.so"
loadmodule "xhttp_rpc.so"

# ----- db_unixodbc params -----
modparam("db_unixodbc", "ping_interval", 600)
modparam("db_unixodbc", "auto_reconnect", 0)
modparam("db_unixodbc", "use_escape_common", 1)

modparam("dispatcher", "db_url","unixodbc://domain\myusername:mypassword@10.0.0.1/Kamailio<http://myusername:mypassword@10.0.0.1/Kamailio>")
modparam("dispatcher", "table_name", "Dispatcher")
modparam("dispatcher", "setid_col", "SetID")
modparam("dispatcher", "destination_col", "Destination")
modparam("dispatcher", "priority_col", "[Priority]")
modparam("dispatcher", "flags_col", "Flags")
modparam("dispatcher", "attrs_col", "Attributes")
modparam("dispatcher", "flags", 2)
modparam("dispatcher", "dst_avp", "$avp(dsdst)")
modparam("dispatcher", "grp_avp", "$avp(dsgrp)")
modparam("dispatcher", "cnt_avp", "$avp(dscnt)")
modparam("dispatcher", "attrs_avp", "$avp(dsattrs)")


The Dispatcher table is loaded just fine on startup of Kamailio.
kamctl fifo ds_list shows the table data.



From: sr-users-bounces at lists.sip-router.org<mailto:sr-users-bounces at lists.sip-router.org> [mailto:sr-users-bounces at lists.sip-router.org<mailto:sr-users-bounces at lists.sip-router.org>] On Behalf Of Grant Bagdasarian
Sent: Friday, September 27, 2013 1:39 PM

To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] Communicate with Kamailio through external application

Right! Totally forgot about that.

Thanks, Kamailio is now receiving the requests!

From: sr-users-bounces at lists.sip-router.org<mailto:sr-users-bounces at lists.sip-router.org> [mailto:sr-users-bounces at lists.sip-router.org] On Behalf Of Charles Chance
Sent: Friday, September 27, 2013 1:35 PM
To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] Communicate with Kamailio through external application

Hi,

Have you added the appropriate listen= and/or port= directive to your config?

http://www.kamailio.org/wiki/cookbooks/4.0.x/core#listen
http://www.kamailio.org/wiki/cookbooks/4.0.x/core#port

Also make sure you have not disabled TCP.

Regards,

Charles


On 27 September 2013 12:27, Grant Bagdasarian <GB at cm.nl<mailto:GB at cm.nl>> wrote:
What am I doing wrong here?

# ----- xhttp params ------
modparam("xhttp", "url_match", "null")

# ----- xhttp_rpc params ------
modparam("xhttp_rpc", "xhttp_rpc_root", "http_rpc")

####### Routing Logic ########

event_route[xhttp:request] {
       xlog("L_INFO", "************************************** RECEIVED NEW HTTP REQUEST:  $hu *********************************");
       xhttp_reply("200", "OK", "text/html","<html><body>OK - Request Received</body></html>");
}

It seems like Kamailio isn't receiving the HTTP requests.
Im doing a simple HTTP GET (http://192.168.1.10/http_rpc) using my browser to see if it hits the event_route.
>From what I understand, the RCP command is in the url of the HTTP request, and is extracted using string transformations.
I've never done anything with RPC directly, so maybe I'm just wrong.

Also, I don't see Kamailio binding to the HTTP port.
The xhttp_rpc_root param only allows alphanumeric values, so I can't specify a full URL.



From: sr-users-bounces at lists.sip-router.org<mailto:sr-users-bounces at lists.sip-router.org> [mailto:sr-users-bounces at lists.sip-router.org<mailto:sr-users-bounces at lists.sip-router.org>] On Behalf Of Grant Bagdasarian
Sent: Friday, September 27, 2013 10:04 AM
To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] Communicate with Kamailio through external application

Thanks, I'll have a look at it.
Looks much easier than setting up Ssh connections programmatically.

From: sr-users-bounces at lists.sip-router.org<mailto:sr-users-bounces at lists.sip-router.org> [mailto:sr-users-bounces at lists.sip-router.org] On Behalf Of Charles Chance
Sent: Wednesday, September 25, 2013 1:12 PM
To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] Communicate with Kamailio through external application

Hi,

Take a look at http://www.kamailio.org/docs/modules/stable/modules/xhttp_rpc.html, which allows you to receive/handle RPC commands over HTTP.

Then use the appropriate RPC command in dispatcher module to reload table: http://www.kamailio.org/docs/modules/stable/modules/dispatcher.html#idp16998512

Regards,

Charles


On 25 September 2013 11:40, Grant Bagdasarian <GB at cm.nl<mailto:GB at cm.nl>> wrote:
Hello,

When adding rows to the dispatcher table, the table in memory needs to be refreshed. Since we have multiple Kamailio instances running on different machines, I'd like to automate the process of reloading the table.
Is there an easy way of doing this with an already existing module, which provides easy connectivity from the outside?
Or do I need to write an application which basically sets up a SSH socket connection with the machine and sends the command "kamctl dispatcher reload" then exit? Not that hard either, but there might be a finer solution available.

Regards,

Grant


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users at lists.sip-router.org<mailto:sr-users at lists.sip-router.org>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


www.sipcentric.com<http://www.sipcentric.com/>

Follow us on twitter @sipcentric<http://twitter.com/sipcentric>

Sipcentric Ltd. Company registered in England & Wales no. 7365592. Registered office: Unit 10 iBIC, Birmingham Science Park, Holt Court South, Birmingham B7 4EJ.

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users at lists.sip-router.org<mailto:sr-users at lists.sip-router.org>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users




www.sipcentric.com<http://www.sipcentric.com/>

Follow us on twitter @sipcentric<http://twitter.com/sipcentric>

Sipcentric Ltd. Company registered in England & Wales no. 7365592. Registered office: Unit 10 iBIC, Birmingham Science Park, Holt Court South, Birmingham B7 4EJ.

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users at lists.sip-router.org<mailto:sr-users at lists.sip-router.org>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


www.sipcentric.com<http://www.sipcentric.com/>

Follow us on twitter @sipcentric<http://twitter.com/sipcentric>

Sipcentric Ltd. Company registered in England & Wales no. 7365592. Registered office: Unit 10 iBIC, Birmingham Science Park, Holt Court South, Birmingham B7 4EJ.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20130927/eef6d6c1/attachment-0001.html>


More information about the sr-users mailing list