Re: [OpenSIPS-Users] Question: how to return string from module function to config script?

2020-10-31 Thread Ovidiu Sas
Hello Elaine,

 A module function in opensips returns and integer.
Based on the return value, you can test if the function was successful or
not.
More details here:
https://www.opensips.org/Documentation/Development-Manual#toc37
Take a look at the big yellow warning at the end of documentation for the
module function for how return codes are interpreted.

If you want to return a string, here’s an example:
https://opensips.org/html/docs/modules/devel/dialplan.html#func_dp_translate
See the out_var parameter.

Hope this helps,
Ovidiu

On Sat, Oct 31, 2020 at 18:57 Elaine Huang  wrote:

> I'm new to opensips and I'm wondering if it's possible for a module
> function to return a string instead of integer?
>
> My wishful thinking is in my config:
>
> $var(myVar) = myFunc(params...);
> # then myVar becomes a string value that I can manipulate, compare, etc
>
>
> If this is not achievable, what's the conventional way to get a string
> from a module function? Is it pseudo variable that I should use?
>
>
> ___
> Users mailing list
> Users@lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-- 
VoIP Embedded, Inc.
http://www.voipembedded.com
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


Re: [OpenSIPS-Users] Opensips-cp 8.3.0 HTTP/1.1 400 Bad Request..

2020-10-31 Thread Mario San Vicente
Hello  Răzvan ,
I was wrong with my diagnosis, cause i stopped receiving the http / 400
error.  But when trying to monitor calls i see that the portal is not
reflecting the real info, i tested dialogs and rtpproxy.
I do see the json reply on a trace, but it is not updated on the portal:

T 127.0.0.1:47632 -> 127.0.0.1: [AP] #137
  POST /mi HTTP/1.1..Host: 127.0.0.1:..Accept: */*..Content-Type:
application/json..Content-Length:
49{"jsonrpc":"2.0","id":1,"method":"rtpproxy_
  show"}"id..._";i#4
#
T 127.0.0.1: -> 127.0.0.1:47632 [A] #138
  ..._..k#)...
#
T 127.0.0.1: -> 127.0.0.1:47632 [AP] #139
  HTTP/1.1 200 OK..Content-Length: 136..Content-Type:
application/json..Date: Sat, 31 Oct 2020 17:34:22
GMT{"jsonrpc":"2.0","result":[{"Set":0,"Nodes

":[{"url":"udp:localhost:2123","index":0,"disabled":0,"weight":1,"recheck_ticks":0}]}],"id":1}.._..k#4

T 127.0.0.1:47644 -> 127.0.0.1: [AP] #204
  POST /mi HTTP/1.1..Host: 127.0.0.1:..Accept: */*..Content-Type:
application/json..Content-Length:
78{"jsonrpc":"2.0","id":1,"method":"dlg_list"
  ,"params":{"index":0,"counter":20}}._J.
#
T 127.0.0.1: -> 127.0.0.1:47644 [A] #205
  @.._
#
T 127.0.0.1: -> 127.0.0.1:47644 [AP] #206
  HTTP/1.1 200 OK..Content-Length: 58..Content-Type:
application/json..Date: Sat, 31 Oct 2020 17:42:14
GMT{"jsonrpc":"2.0","result":{"count":0,"Dialo
  gs":[]},"id":1}._4...4.

Aside notes:
When enabling this line #modparam("mi_http", "root", "opensips_mi") , i can
see the mi portal.  http://x.x.x.x:/mi , which has lots of
aditional info,  but i have to disable it to get the json response and just
get an http response pointing to the mi interface:
T 127.0.0.1: -> 127.0.0.1:47654 [AP] #256
  HTTP/1.1 200 OK..Content-Length: 1886..Content-Type: text/html..Date:
Sat, 31 Oct 2020 17:55:45 GMTOpenSIPS Management
Interface
  body{margin:0;}body,p,div,td,th,tr,form,ol,ul,li,input,textarea,select,a{font-family:"lucida
grande",verdana,geneva,aria

l,helvetica,sans-serif;font-size:14px;}a:hover{text-decoration:none;}a{text-decoration:underline;}.foot{padding-top:40px;font-size:10px;color:#33;}
  .foot
a{font-size:10px;color:#00;}table.center{margin-left:auto;margin-right:auto;}https://opensips.org/favicon.png;>.OpenSIPS MI HTML InterfaceOpenSIPS
(3.1.0-dev (x86_6
  4/linux)) is running since Sat Oct 31 11:55:35
2020...statistics.core.blacklists.httpd.tm.usrloc.dialog.nathelper.rtpproxy.db_text.drouti
  ngOpenSIPS web siteCopyright  2011-2015
http://www.voipembedded.com/;>VoIP Embedded, Inc.. All rights
res
  erved!.._X.t.4

Thank in advace.


On Fri, Oct 30, 2020 at 8:45 PM Mario San Vicente 
wrote:

> Hello  Răzvan ,
>
> Thanks alot, that made the trick.
>
> I will check if something is not matching with the monit page cause that
> is not working ,  but that's another story.
>
> Best regards.
> Mario
>
>
>
>
>
> On Thu, Oct 29, 2020 at 3:49 AM Răzvan Crainea 
> wrote:
>
>> As I see in your logs, OpenSIPS CP uses the `json` URL path for querying
>> MI, whereas the default root path is `mi`[1]. Either change the `root`
>> to `json`, or modify your OpenSIPS CP boxes config to `mi`.
>>
>> [1] https://opensips.org/docs/modules/3.1.x/mi_http.html#param_root
>>
>> Best regards,
>>
>> Răzvan Crainea
>> OpenSIPS Core Developer
>> http://www.opensips-solutions.com
>>
>> On 10/28/20 11:23 PM, Mario San Vicente wrote:
>> >Thanks for the answer Johan,
>> >
>> > But i see that; the *mi_json* module has been renamed to
>> > *mi_http* module.  and so: failed to load module mi_json.so
>> > https://www.opensips.org/Documentation/Migration-2-4-0-to-3-0-0
>> >
>> > I am using opensips 3.1
>> > I have this modules:
>> >
>> > loadmodule "httpd.so"
>> > modparam("httpd", "port", )
>> >  MI_HTTP module
>> > loadmodule "json.so"
>> > #loadmodule "mi_json.so"
>> > loadmodule "mi_http.so"
>> >
>> > Any other clue?
>> >
>> > Thank you
>> >
>> >
>> > ___
>> > 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
>>
>
>
> --
> Mario San Vicente
> Cheers!
>


-- 
Mario San Vicente
Cheers!
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users