[SR-Users] Invoking RPC commands over HTTP

Aleksandar Sosic alex.sosic at timenet.it
Fri Mar 2 10:29:06 CET 2018


Hi Ben,

we're using something like this to do dispatcher.reload:

```
event_route[xhttp:request] {
if ($hu =~ "^/rpc") {
$var(command) = $(hu{s.select,2,/});
$var(parameter) = $(hu{s.select,3,/});

if($var(command) == "reload.dispatchers") {
route(DISPATCHER_LIST);
xhttp_reply("200", "OK", "text/html", "Dispatchers Set for RELOAD");
exit;
}
...
}
```

And then in the DISPATCHER_LIST route we do an API call for fetching
the updated dispatcher list for that node.
After the dispatcher list is updated we just run:
jsonrpc_exec('{"jsonrpc": "2.0", "method": "dispatcher.reload", "id": "1"}');

So you can just put a `jsonrpc_exec` inside the event_route[xhttp:request].

Kind regards,
--
Aleksandar Sosic
mail: alex.sosic at timenet.it
skype: alex.sosic
cell: +385 91 2505 146


On Fri, Mar 2, 2018 at 10:16 AM, Ben Hood <0x6e6562 at gmail.com> wrote:
> Cool, many thanks for the heads up.
>
> So jsonrpc_dispatch() in the request handler binds to the method
> parameter in the JSON blob sent by the client to the corresponding
> internal management function?
>
>
> On Fri, Mar 2, 2018 at 9:12 AM, Daniel-Constantin Mierla
> <miconda at gmail.com> wrote:
>> you can do jsonrpc over http/s by using jsonrpcs+xhttp modules --
>> example at:
>>
>>   -
>> https://www.kamailio.org/docs/modules/stable/modules/jsonrpcs.html#jsonrpcs.f.jsonrpc_dispatch
>>
>> There is also an xmlrpc module that works over http/s.
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users



More information about the sr-users mailing list