Hello all,
I'm in the process of converting an on-host install of Kamailio to be run inside a docker container. A part of this Kamailio install is a small node.js application that modifies the sqlite database Kamailio uses, then runs `kamctl fifo ds_reload` to tell Kamailio to reload its knowledge from that database.
I'm trying to split these two processes (the node app and the Kamailio server) into separate docker containers, in an effort to follow the one-process-per-container philosophy, but having trouble figure out exactly how I should perform the ds_reload step without access to the kamctl in the Kamailio container.
The obvious direction that I'm looking is to perform some sort of network request, since I can configure the two docker containers to have network access to each other. Is there some way to perform a ds_reload over the network?
Thanks for all you do. Kamailio is a great SIP server and we use it to great effect.
-Chad McElligott
Hello Chad,
My suggestion would be to use the 'jsonrpc-s' module:
http://kamailio.org/docs/modules/4.4.x/modules/jsonrpc-s.html
This runs over the 'xhttp' module, and requires enabling the TCP transport. However, the end result is that with very little config script, it will allow you to run next-generation RPC commands, including the equivalent of 'ds_reload', 'dispatcher.reload':
http://kamailio.org/docs/modules/4.4.x/modules/dispatcher.html#dispatcher.f....
You would run it using something like this:
$ curl -v -H 'Content-Type: application/json' \ -H 'Call-ID: abc12' \ -d '{"jsonrpc": "2.0", "method": "dispatcher.reload", "id": "0deadb33f"}' \ http://your.kamailio.server:5060/rpc_path/
The basic boilerplate is as simple as:
----
listen=tcp:0.0.0.0:5060
loadmodule "xhttp" loadmodule "jsonrpc-s"
modparam("xhttp", "url_match", "^/rpc_path/") modparam("jsonrpc-s", "pretty_format", 1)
event_route[xhttp:request] { if($hu =~ "^/rpc_path") jsonrpc_dispatch(); else xhttp_reply("404", "Not Found", "text/html", ""); }
----
Of course, in the real world, you'll want to consider authentication, IP ACLs, and other things that go into some sort of security thought process. But that's the basic idea.
-- Alex
Great, thanks Alex. I will give that a shot and see how it goes.
On Aug 26, 2016 5:42 PM, "Alex Balashov" abalashov@evaristesys.com wrote:
Hello Chad,
My suggestion would be to use the 'jsonrpc-s' module:
http://kamailio.org/docs/modules/4.4.x/modules/jsonrpc-s.html
This runs over the 'xhttp' module, and requires enabling the TCP transport. However, the end result is that with very little config script, it will allow you to run next-generation RPC commands, including the equivalent of 'ds_reload', 'dispatcher.reload':
http://kamailio.org/docs/modules/4.4.x/modules/dispatcher. html#dispatcher.f.reload
You would run it using something like this:
$ curl -v -H 'Content-Type: application/json' \ -H 'Call-ID: abc12' \ -d '{"jsonrpc": "2.0", "method": "dispatcher.reload", "id": "0deadb33f"}' \ http://your.kamailio.server:5060/rpc_path/
The basic boilerplate is as simple as:
listen=tcp:0.0.0.0:5060
loadmodule "xhttp" loadmodule "jsonrpc-s"
modparam("xhttp", "url_match", "^/rpc_path/") modparam("jsonrpc-s", "pretty_format", 1)
event_route[xhttp:request] { if($hu =~ "^/rpc_path") jsonrpc_dispatch(); else xhttp_reply("404", "Not Found", "text/html", ""); }
Of course, in the real world, you'll want to consider authentication, IP ACLs, and other things that go into some sort of security thought process. But that's the basic idea.
-- Alex
-- Alex Balashov | Principal | Evariste Systems LLC
Tel: +1-706-510-6800 (direct) / +1-800-250-5920 (toll-free) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hey Alex, this worked well for me.
As far as the security portion goes, I just exposed the tcp on a separate port that is only accessible to linked containers. I feel like that should be sufficient.
Thank you for the direction!
-- Chad McElligott Digium, Inc. | Senior Software Developer 445 Jan Davis Drive NW - Huntsville, AL 35806 - US direct: +1-256-434-5151 / cmcelligott@digium.com
On Fri, Aug 26, 2016 at 6:05 PM, Chad McElligott cmcelligott@digium.com wrote:
Great, thanks Alex. I will give that a shot and see how it goes.
On Aug 26, 2016 5:42 PM, "Alex Balashov" abalashov@evaristesys.com wrote:
Hello Chad,
My suggestion would be to use the 'jsonrpc-s' module:
http://kamailio.org/docs/modules/4.4.x/modules/jsonrpc-s.html
This runs over the 'xhttp' module, and requires enabling the TCP transport. However, the end result is that with very little config script, it will allow you to run next-generation RPC commands, including the equivalent of 'ds_reload', 'dispatcher.reload':
http://kamailio.org/docs/modules/4.4.x/modules/dispatcher.ht ml#dispatcher.f.reload
You would run it using something like this:
$ curl -v -H 'Content-Type: application/json' \ -H 'Call-ID: abc12' \ -d '{"jsonrpc": "2.0", "method": "dispatcher.reload", "id": "0deadb33f"}' \ http://your.kamailio.server:5060/rpc_path/
The basic boilerplate is as simple as:
listen=tcp:0.0.0.0:5060
loadmodule "xhttp" loadmodule "jsonrpc-s"
modparam("xhttp", "url_match", "^/rpc_path/") modparam("jsonrpc-s", "pretty_format", 1)
event_route[xhttp:request] { if($hu =~ "^/rpc_path") jsonrpc_dispatch(); else xhttp_reply("404", "Not Found", "text/html", ""); }
Of course, in the real world, you'll want to consider authentication, IP ACLs, and other things that go into some sort of security thought process. But that's the basic idea.
-- Alex
-- Alex Balashov | Principal | Evariste Systems LLC
Tel: +1-706-510-6800 (direct) / +1-800-250-5920 (toll-free) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Not a problem. Glad it worked out!
-- Alex
-- Principal, Evariste Systems LLC (www.evaristesys.com)
Sent from my Google Nexus.