asipto / siremis

Web Admin Interface for Kamailio
http://www.siremis.org
98 stars 46 forks source link

jsonrpc not working #26

Closed powerpbx closed 6 years ago

powerpbx commented 6 years ago

Fresh Install Kamailio v5.1 Siremis from master branch https://github.com/asipto/siremis.git Debian v9 with PHP v7.0 (Also tried Debian v8 and PHP v5.6) php-mysql php-gd php-curl php-xml php-xmlrpc php-json libapache2-mod-php php-pear

In kamailio.cfg I have

loadmodule "jsonrpcs.so"
modparam("jsonrpcs", "transport", 0)
modparam("jsonrpcs", "dgram_socket", "/tmp/kamailio_rpc.sock")

It doesn't appear to be working. In GUI > SIP ADMIN MENU > Command Services > JSONRPC Commands if I run any command it gives a generic system error webpage.

These are the only errors I see in the apache logs. Nothing in Kamailio logs

[Wed Jun 13 10:00:18.387204 2018] [:error] [pid 6031] [client x.x.x.52:52130] PHP Warning: strstr() expects parameter 1 to be string, resource given in /var/www/siremis/openbiz/bin/ErrorHandler.php on line 154, referer: http://x.x.x.166/siremis/sipadmin/jrcmds

[Wed Jun 13 10:00:18.391287 2018] [:error] [pid 6031] [client x.x.x.52:52130] socket bind failed: No such file or directory, referer: http://x.x.x.166/siremis/sipadmin/jrcmds

miconda commented 6 years ago

Can you paste here the content of your siremis/modules/sipadmin/service/siremisJRCommands.xml?

powerpbx commented 6 years ago

That file was not changed so it is whatever is currently in master branch.

<?xml version="1.0" standalone="no"?>
<PluginService Name="siremisJRCommands" Package="asipto" Class="siremisJRCommands">
    <JRConfig name="JRConfig" type="unixsock" mode="rich">
        <!-- used for type="http" -->
        <RSocket name="rsocket" address="http://127.0.0.1:5060/RPC2" timeout="3"
                 username="alice" password="wonderland"/>
        <!-- used for type="udp" -->
        <UDPLocal name="udplocal" address="127.0.0.1" port="8044" timeout="3.0"/>
        <UDPRemote name="udpremote" address="127.0.0.1" port="8033" timeout="3.0"/>
        <!-- used for type="unixsock" *** note: avoid sockets in /tmp/ if you haven't reconfigured systemd -->
        <UnixSockLocal name="unixsocklocal" address="/var/run/siremis/siremis_rpc.sock" timeout="3.0"/>
        <UnixSockRemote name="unixsockremote" address="/var/run/kamailio/kamailio_rpc.sock" timeout="3.0"/>
        <JRCommands>
            <cmd name="help" title="List RPC Commands" command="system.listMethods"/>
            <cmd name="uptime" title="Server - Uptime" command="core.uptime"/>
            <cmd name="psx" title="Server - List Processes" command="core.psx"/>
            <cmd name="getstatsall" title="Server - All Statistics" command="stats.get_statistics all"/>
            <cmd name="corexsockets" title="Server - Listen Sockets" command="corex.list_sockets"/>
            <cmd name="corexaliases" title="Server - Domain Aliases" command="corex.list_aliases"/>
            <cmd name="dslist" title="Dispatcher - List Records" command="dispatcher.list"/>
            <cmd name="dsreload" title="Dispatcher - Reload Records" command="dispatcher.reload"/>
            <cmd name="uldump" title="UsrLoc - Location Records" command="ul.dump"/>
            <cmd name="uldumpbrief" title="UsrLoc - Brief Location Records" command="ul.dump brief"/>
            <cmd name="addrlist" title="Permissions - List IP Address Records" command="permissions.addressDump"/>
            <cmd name="subnlist" title="Permissions - List IP Subnet Records" command="permissions.subnetDump"/>
            <cmd name="addrreload" title="Permissions - Reload DB Address Records" command="permissions.addressReload"/>
            <cmd name="mtlist" title="MTree - List Records" command="mtree.list"/>
            <cmd name="mtreload" title="MTree - Reload Records" command="mtree.reload"/>
            <cmd name="pdtlist" title="PDT - List Records" command="pdt.list"/>
            <cmd name="pdtreload" title="PDT - Reload Records" command="pdt.reload"/>
        </JRCommands>
    </JRConfig>
</PluginService>
miconda commented 6 years ago

Based on siremis config, the path for jsonrpcs socket has to be /var/run/kamailio/kamailio_rpc.sock, try to set:

modparam("jsonrpcs", "dgram_socket", "/var/run/kamailio/kamailio_rpc.sock")

The folder /var/run/siremis/ has to be created with web server having permissions to write to it.

Also be sure that there are enough permissions for the web server and kamailio to access the the two unixsocket files.

The alternative to try is to use udp sockets.

powerpbx commented 6 years ago

Thank you,

The permission of the sock file was the problem. The solution was.

modparam("jsonrpcs", "dgram_socket", "/var/run/kamailio/kamailio_rpc.sock")
modparam("jsonrpcs", "dgram_mode", 0666)
yboujraf commented 4 years ago

Dear,

I followed how to install siremis 5.1 with kamailio 5.3 and enabling jsonrpcs module but I still have this error message in /var/log/apache2/error.log

[Mon Nov 04 03:55:40.741085 2019] [php7:warn] [pid 772] [client 192.168.0.230:50058] PHP Warning: strstr() expects parameter 1 to be string, resource given in /var/www/siremis/openbiz/bin/ErrorHandler.php on line 158, referer: http://10.0.100.226/siremis/sipadmin/jrcmds [Mon Nov 04 03:55:40.742481 2019] [php7:notice] [pid 772] [client 192.168.0.230:50058] socket bind failed: No such file or directory, referer: http://10.0.100.226/siremis/sipadmin/jrcmds

I added those lines in the kamailio.cfg 👍 modparam("jsonrpcs", "dgram_socket", "/var/run/kamailio/kamailio_rpc.sock") modparam("jsonrpcs", "dgram_mode", 0666)

but no change.

Best Regards, Youssef

josefig commented 3 years ago

@yboujraf did you find any solution? I'm trying to do the same with kamailio 5.3 and didn't work on Centos 7. I have the same problem that you had.

yboujraf commented 3 years ago

@josefig

No answer from the time i poster my issue.

josefig commented 3 years ago

I found the solution: It seems I needed to create the folder for /var/run/siremis which described is in the siremis/modules/sipadmin/service/siremisJRCommands.xml file and give permissions to the apache server to write. In addition, I added the following in kamailio.cfg :

modparam("jsonrpcs", "dgram_socket", "/var/run/kamailio/kamailio_rpc.sock")
modparam("jsonrpcs", "dgram_mode", 0666)

and worked! It seems the siremis PHP code is kind of old and must be easier to add a validator (Exception handler or something) to that folder or even on the installation process create it.

yboujraf commented 3 years ago

Thanks Dear

On Fri, 16 Oct 2020, 01:35 Jose N Figueroa, notifications@github.com wrote:

I found the solution: It seems I needed to create the folder for /var/run/siremis which described is in the siremis/modules/sipadmin/service/siremisJRCommands.xml file and give permissions to the apache server to write. In addition, I added the following in kamailio.cfg :

modparam("jsonrpcs", "dgram_socket", "/var/run/kamailio/kamailio_rpc.sock") modparam("jsonrpcs", "dgram_mode", 0666)

and worked! It seems the siremis PHP code is kind of old and must be easier to add a validator (Exception handler or something) to that folder or even on the installation process create it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/asipto/siremis/issues/26#issuecomment-709643735, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABO5YWVM2XTCCWRAU35Y5Q3SK6BKRANCNFSM4FE2S5XA .