Re: [OpenSIPS-Users] - Not sending ACK back!

2022-10-22 Thread Daniel Zanutti
Hi Nitesh

I think the default OPENSIPS.CFG script has a Registrar Server and the
Lookup function. Please take a look there. To call then, you have to use
lookup function.

The ACK missing feature maybe related to NAT problems. Where is the ACK
lost? Did origin sent to Opensips? Did opensips forward to destination?
Please take a deep look at default opensips.cfg, I tested it in the past
and worked fine.


On Fri, Oct 21, 2022 at 3:05 PM Nitesh Divecha 
wrote:

> Daniel,
>
> Thanks for your detailed email. Much appreciated!
>
> Yes I totally understand about OpenSIPS and I'm going over all the
> documentations and tutorials I can find! My background is from Asterisk, so
> with that mentality I'm tackling OpenSIPS.
>
> Asterisk (Context) vs OpenSIPS (C-style script), it is a huge challenge
> but getting the hang of it!
>
> Lets pick option (3) Routing local calls (ATA to ATA)... Do you have any
> examples I can follow and set up a local route? I set up two extensions
> (8883456 and 7773456) via OpenSIPS Control Panel and I was able to register
> two ATA's. I do have the Registrar module loaded... How can I call each
> other?
>
>  REGISTRAR module
>
> loadmodule "registrar.so"
>
> modparam("registrar", "default_expires", 3600)
>
> modparam("registrar", "min_expires", 60)
>
> modparam("registrar", "max_expires", 120)
>
> # modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")
>
> # modparam("registrar", "received_avp", "$avp(received_nh)")/* uncomment
> the next line not to allow more than 10 contacts per AOR */
>
> modparam("registrar", "max_contacts", 10)
>
> modparam("registrar", "received_avp", "$avp(rcv)")
>
> modparam("registrar", "retry_after", 30)
>
>
> Regarding option (4) - I have both options. IP to IP and User/Pass
> authentication provider. Using User/Pass I was able to register OpenSIPS as
> UAC to a remote server and I was able to make outbound calls but call keeps
> on dropping due to no ACK.
>
> Cheers,
> Nitesh
>
>
>
>
>
> On Fri, Oct 21, 2022 at 1:26 PM Daniel Zanutti 
> wrote:
>
>> Hi Nitesh
>>
>> As you already know, opensips is a low level software. You have to
>> understand several aspects of SIP, network, RTP, DNS that when you use
>> Asterisk, most you don't need to understand deep.
>>
>> Trying to help you, your script is way simple for you achievements. You
>> need:
>> 1) Check NAT on all request + all replies. This is to fix your SIP
>> messages.
>>
>> 2) Check if you need to apply RTPPROXY on the call. You can use the
>> "engage" function on INVITE then forget about it OR you can use manual way
>> with "offer" function and handle all scenarios manually. For example, call
>> the "answer" function on the 200 OK. Then delete on BYE.
>>
>> 3) Routing local calls (ATA to ATA) you need to handle the Register first
>> with "save" function, then later handle the INVITE with the "lookup"
>> function, both of Registrar module.
>>
>> 4) PSTN can be used as a direct route or some dynamic routing solution.
>> Make it work first with direct routing. Need to check how authenticate
>> works on your carrier. If IP based will be fine, if user/pass you need to
>> make your opensips authenticate, it's a little harder.
>>
>> 5) DID - You have to create some specific INBOUND rules. Calls will be
>> anonymous or authenticated?
>>
>> 6) Fax - Better solve other issues first.
>>
>> Hope this gives you some direction. Look for some tutorials.
>>
>> Regards
>>
>> On Fri, Oct 21, 2022 at 11:11 AM Nitesh Divecha <
>> aviator.nites...@gmail.com> wrote:
>>
>>> Hello All,
>>>
>>> I have been scratching my head for a few days now... Just to recap:
>>>
>>> I'm a newbie with OpenSIPS so bear with me... I got OpenSIPS 3.3.1
>>> (residential) running on Debian 11 with OpenSIPS Control Panel 9.3.2 and
>>> MySQL.
>>>
>>> My goal is to:
>>> 1) Make two ATA's register and call each other (locally)... *Stopped
>>> working, I think routing logic is missing.*
>>> 2) Make ATA to call PSTN via an outbound SIP trunk or DID provider... *No
>>> ACK sent to Outbound provider.*
>>> 3) Receive inbound calls from PSTN or SIP trunk and forward it to
>>> registered ATA... *Getting rejected.*
>>> 4) Able to send and receive faxes from and to PSTN... *Haven't even
>>> touched.*
>>>
>>> Fast forward... I did achieve a few of my goals but they stopped
>>> working... You fix one thing and you break others...
>>>
>>> My current issue is OpenSIPS is not sending ACK back to the Outbound
>>> provider when I make calls to PSTN thus calls are getting dropped from the
>>> Outbound provider due to no ACK. This issue started when I implemented
>>> topology_hiding('C"), rtpproxy_offer("ro"), uac_replace_from( ,
>>> "$avp(furi)").
>>>
>>> Here is my code snippet:
>>>
>>> ### Routing Logic 
>>>
>>>
>>> # main request routing logic
>>>
>>>
>>> route{
>>>
>>>
>>> #if ($rU=~"^\+[1-9][0-9]+$") {
>>>
>>> if (dp_translate(10 ,$rU ,$rU) ) {
>>>
>>> xlog("*** 2. Dial plan translate from source $avp(src)
>>> to 

Re: [OpenSIPS-Users] early dialog termination

2022-10-22 Thread mayamatakeshi
Hi,
I've been following this discussion as I have a similar use case.
I have created a PR offering a new function t_reply_by_callid for the
module tm to simplify this:
  https://github.com/OpenSIPS/opensips/pull/2937

Regards,
Takeshi

On Thu, Oct 20, 2022 at 4:04 PM Bogdan-Andrei Iancu 
wrote:

> Ivan,
>
> Actually a simpler approach will be to use t_wait_for_new_branches()
> instead of that t_write function, it should do the same trick (postponing
> the deletion of the transaction), but without any side effects.
>
> Regards,
>
> Bogdan-Andrei Iancu
>
> OpenSIPS Founder and Developer
>   https://www.opensips-solutions.com
> OpenSIPS Bootcamp 5-16 Dec 2022, online
>   https://www.opensips.org/training/OpenSIPS_eBootcamp_2022/
>
> On 10/19/22 10:21 AM, Ryzhik Ivan wrote:
>
> Sorry, I mean no sleep, i mean async( sleep($var(wait_time)), after_sleep
> );
> Regards, Ivan.
>
> вт, 18 окт. 2022 г. в 14:42, Bogdan-Andrei Iancu :
>
>> Hi,
>>
>> yes, call it before ending the REQUEST route. I'm 100% the transaction is
>> not deleted before the end of the route. And try to use the unix sock
>> flavor for the function, not the fifo one.
>>
>> DO NOT use the sleep, you will block your whole opensips.
>>
>> Regards,
>>
>> Bogdan-Andrei Iancu
>>
>> OpenSIPS Founder and Developer
>>   https://www.opensips-solutions.com
>> OpenSIPS Bootcamp 5-16 Dec 2022, online
>>   https://www.opensips.org/training/OpenSIPS_eBootcamp_2022/
>>
>> On 10/17/22 11:56 AM, Ryzhik Ivan wrote:
>>
>> Hi, did you mean that i must call t_write_req once before REQUEST_ROUTE
>> is finished? In this case the transaction was removed.
>> "even if you do not have to actually write anything to outer world -
>> just fake it." - i must use fifo and i must read data from it, in else
>> we got:
>> ERROR:tm:write_to_fifo: nobody listening on [/tmp/moh.fifo] fifo for
>> reading!
>> ERROR:tm:t_write_req: write_to_fifo failed
>> And last question is may I use sleep(20) at the end of route to keep
>> transaction? or can i use modparam("tm", "wt_timer", 20)?
>> Regards, Ivan
>>
>> пн, 17 окт. 2022 г. в 09:38, Bogdan-Andrei Iancu :
>>
>>> Hi Ryzhik,
>>>
>>> Right, the transaction must be forced to stay until you are done with a
>>> final reply. Unfortunately there is no clear way to do this from script
>>> (this may be subject of further small improvements), but you can try taking
>>> advantage of the `t_write_req` [1] for this purpose, even if you do not
>>> have to actually write anything to outer world - just fake it.
>>>
>>>
>>> [1]
>>> https://opensips.org/html/docs/modules/3.2.x/tm.html#func_t_write_req
>>>
>>> Regards,
>>>
>>> Bogdan-Andrei Iancu
>>>
>>> OpenSIPS Founder and Developer
>>>   https://www.opensips-solutions.com
>>> OpenSIPS Summit 27-30 Sept 2022, Athens
>>>   https://www.opensips.org/events/Summit-2022Athens/
>>>
>>> On 10/13/22 2:45 PM, Ryzhik Ivan wrote:
>>>
>>> Hi.
>>> One more question.
>>> Everything works fine except the transaction was deleted after 15
>>> sec after the initial route was finished.
>>> on INVITE i last do t_reply_with_body(183, "Session progress", ...) and
>>> than exit;
>>>
>>> on end route log :
>>>
>>> 2022-10-13T10:58:01.994598+00:00  DBG:tm:_reply_light: reply sent out.
>>> buf=0x7f558a087d98: SIP/2.0 1..., shmem=0x7f5549797470: SIP/2.0 1
>>> 2022-10-13T10:58:01.994676+00:00  DBG:tm:_reply_light: finished
>>>
>>> 2022-10-13T10:58:01.995835+00:00  DBG:tm:do_t_cleanup: transaction
>>> 0x7f5549793b18 already updated! Skipping update!
>>> 2022-10-13T10:58:01.996020+00:00  DBG:tm:cleanup_uac_timers: RETR/FR
>>> timers reset
>>> 2022-10-13T10:58:01.996202+00:00  *DBG:tm:insert_timer_unsafe: [2]:
>>> 0x7f5549793b98 (12)*
>>> 2022-10-13T10:58:01.996317+00:00 * DBG:tm:t_unref: UNREF_UNSAFE:
>>> [0x7f5549793b18] after is 0*
>>> 2022-10-13T10:58:01.996488+00:00  DBG:core:destroy_avp_list: destroying
>>> list (nil)
>>> 2022-10-13T10:58:01.996673+00:00  DBG:core:receive_msg: cleaning up
>>>
>>> 2022-10-13T10:58:07.651091+00:00*  DBG:tm:timer_routine: timer
>>> routine:2,tl=0x7f5549793b98 next=(nil), timeout=12*
>>> 2022-10-13T10:58:07.651332+00:00  DBG:tm:wait_handler: removing
>>> 0x7f5549793b18 from table
>>> 2022-10-13T10:58:07.651425+00:00  DBG:tm:delete_ce*ll: delete
>>> transaction 0x7f5549793b18*
>>> 2022-10-13T10:58:07.651513+00:00  DBG:tm:wait_handler: done
>>>
>>> Can you tell me how I can i fix this? Transaction marked safe for
>>> deletion...
>>> Regards, Ivan
>>>
>>> ср, 12 окт. 2022 г. в 13:11, Bogdan-Andrei Iancu :
>>>
 Perfect !!!

 Bogdan-Andrei Iancu

 OpenSIPS Founder and Developer
   https://www.opensips-solutions.com
 OpenSIPS Summit 27-30 Sept 2022, Athens
   https://www.opensips.org/events/Summit-2022Athens/

 On 10/12/22 1:09 PM, Ryzhik Ivan wrote:

 I found a solution. hex strings are reversed).
 Thank you very much!

 ср, 12 окт. 2022 г. в 12:59, Ryzhik Ivan :

> and one more research: $T_id returns hex encoded label.hashid
> but