Re: [OpenSIPS-Users] too many parameters for command

2020-12-06 Thread Tomi Hakkarainen
Hi,

I would pass params in a python dictionary if its alllowed.

Tomi

On 6. Dec 2020, at 14.35, Elaine Huang  wrote:


Hi Vlad,

Thanks. 

What would you do if you need to pass multiple parameters to a function? I'm 
thinking of compile the params into one string (separated by comma maybe) and 
parse them in the python function, but that's hacky.

On Sat., 5 Dec. 2020, 03:29 Vlad Patrascu,  wrote:
> Hi Elaine,
> 
> Unfortunately the documentation is actually misleading and the function 
> accepts only one extra argument for passing to python.
> 
> Regards,
> 
> -- 
> Vlad Patrascu
> OpenSIPS Developer
> http://www.opensips-solutions.com
> On 04.12.2020 11:30, Elaine Huang wrote:
>> Hi,
>> 
>> I wrote a python function that takes 3 parameters (excluding msg):
>> 
>> 
>> class MyClass:
>>   …
>>   my_f(self, msg, param1, param2, param3):
>> …
>>   …
>> 
>> 
>> While the python module readme suggests it can accept extra args (more than 
>> 1), opensips fail to start with error: too many parameters for command 
>> 
>> 
>> my config code:
>> python_exec("my_f", param1, param2, param3)
>> 
>> 
>> It can start if I change it to:
>> python_exec("my_f", param1)
>> 
>> 
>> Any idea why?
>> 
>> 
>> OpenSIPS version: 3.1
>> 
>> 
>> 
>> Kind Regards,
>> Elaine
>> 
>> 
>> 
>> ___
>> Users mailing list
>> Users@lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> ___
> Users mailing list
> Users@lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


Re: [OpenSIPS-Users] Opensips-cp 8.3.0 / Call to undefined function json_encode()

2020-12-06 Thread Maciej Bylica
Hello

Could somebody please point me to where I should look for the clue ?

Thanks
Maciej

pon., 30 lis 2020 o 15:51 Maciej Bylica  napisał(a):

> Hello
>
>
> I am struggling with OpenSIPS-CP 8.3.0 (.zip source) configuration on
> Centos 8.2
>
> Opensips 3.1 uses port 8000 to interop with opensips-cp, but there are no
> tcpdump packets on that port.
>
> It turned out that i am getting following errors on php level:
>
>
> [30-Nov-2020 14:13:54 UTC] PHP Warning:  Creating default object from
> empty value in
> /var/www/html/opensips-cp/config/tools/system/drouting/local.inc.php on
> line 24
>
> [30-Nov-2020 14:13:54 UTC] PHP Stack trace:
>
> [30-Nov-2020 14:13:54 UTC] PHP   1. {main}()
> /var/www/html/opensips-cp/web/tools/system/drouting/apply_changes.php:0
>
> [30-Nov-2020 14:13:54 UTC] PHP   2. require()
> /var/www/html/opensips-cp/web/tools/system/drouting/apply_changes.php:25
>
> [30-Nov-2020 14:13:54 UTC] PHP Error:  Call to undefined function
> json_encode() in /var/www/html/opensips-cp/web/common/mi_comm.php on line 31
>
> [30-Nov-2020 14:13:54 UTC] PHP Stack trace:
>
> [30-Nov-2020 14:13:54 UTC] PHP   1. {main}()
> /var/www/html/opensips-cp/web/tools/system/drouting/apply_changes.php:0
>
> [30-Nov-2020 14:13:54 UTC] PHP   2. mi_command($command = 'dr_reload',
> $params_array = NULL, $mi_url = 'json:127.0.0.1:8000/JSON', $errors =
> NULL)
> /var/www/html/opensips-cp/web/tools/system/drouting/apply_changes.php:43
>
> [30-Nov-2020 14:13:54 UTC] PHP   3. write2json($command = 'dr_reload',
> $params_array = NULL, $json_url = '127.0.0.1:8000/JSON', $errors = NULL)
> /var/www/html/opensips-cp/web/common/mi_comm.php:87
>
> [30-Nov-2020 14:13:54 UTC] PHP Fatal error:  Uncaught Error: Call to
> undefined function json_encode() in
> /var/www/html/opensips-cp/web/common/mi_comm.php:31
>
> Stack trace:
>
> #0 /var/www/html/opensips-cp/web/common/mi_comm.php(87):
> write2json('dr_reload', NULL, '127.0.0.1:8000/...', NULL)
>
> #1
> /var/www/html/opensips-cp/web/tools/system/drouting/apply_changes.php(43):
> mi_command('dr_reload', NULL, 'json:127.0.0.1:...', NULL)
>
> #2 {main}
>
>   thrown in /var/www/html/opensips-cp/web/common/mi_comm.php on line 31
>
>
> I followed installation document located at
> http://controlpanel.opensips.org/documentation.php.
>
>
> Here is my boxes.global.inc.php config:
>
> $boxes[$box_id]['mi']['conn']="json:127.0.0.1:8000/JSON";
>
> but i also tried with
>
> $boxes[$box_id]['mi']['conn']="json:127.0.0.1:8000/mi";
>
> with the same effect.
>
>
> Opensips (compiled from the sources) has got following modules up and
> running:
>
>
> HTTP
>
> loadmodule "httpd.so"
>
> modparam("httpd", "port", 8000)
>
>
> ###JSON
>
> loadmodule "json.so"
>
>
> ###MI_HTTP
>
> loadmodule "mi_http.so"
>
>
> Could you please point me where the problem might be located ?
>
>
> Thanks
>
> Maciej
>
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


Re: [OpenSIPS-Users] too many parameters for command

2020-12-06 Thread Elaine Huang
Hi Vlad,

Thanks.

What would you do if you need to pass multiple parameters to a function?
I'm thinking of compile the params into one string (separated by comma
maybe) and parse them in the python function, but that's hacky.

On Sat., 5 Dec. 2020, 03:29 Vlad Patrascu,  wrote:

> Hi Elaine,
>
> Unfortunately the documentation is actually misleading and the function
> accepts only one extra argument for passing to python.
>
> Regards,
>
> --
> Vlad Patrascu
> OpenSIPS Developerhttp://www.opensips-solutions.com
>
> On 04.12.2020 11:30, Elaine Huang wrote:
>
> Hi,
>
> I wrote a python function that takes 3 parameters (excluding msg):
>
>
> class MyClass:
>   …
>   my_f(self, msg, param1, param2, param3):
> …
>   …
>
>
> While the python module readme suggests it can accept extra args (more
> than 1), opensips fail to start with error: too many parameters for command
> 
>
> my config code:
> python_exec("my_f", param1, param2, param3)
>
>
> It can start if I change it to:
> python_exec("my_f", param1)
>
>
> Any idea why?
>
>
> OpenSIPS version: 3.1
>
>
>
> Kind Regards,
> Elaine
>
>
> ___
> Users mailing 
> listUsers@lists.opensips.orghttp://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
> ___
> Users mailing list
> Users@lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users