[OpenSIPS-Users] OpenSIPS+asterisk: cannot place call

Anca Vamanu anca at opensips.org
Mon Sep 27 12:27:34 CEST 2010


Hi Stefano,

I suppose that you have the nat traversal handled also on opensips, 
right? ( since the host part of the clients registration in asterisk 
points to opensips). Then in this case it is normal that the flow of the 
invite is the following:
sip client -> opensips -> asterisk -> opensips (again)
So you must take care when the Invite arrives the second time at 
opensips not to send it again to asterisk. For this do a filter after 
the source ip and port, so you should have:

if (is_method("INVITE")) {
	if (!ds_is_in_list("$si", "$sp")) ) /* if it's not from asterisk */
		if (!ds_select_dst("1", "5")) {
	    ....
		
	} else
		route(1); /* send it out */


Regards,

-- 
Anca Vamanu
www.voice-system.ro



On 09/27/2010 12:01 PM, Stefano Sasso wrote:
> Hello,
>    I started testing OpenSIPS with my asterisk cluster.
> For this testing configuration I'm using only one asterisk server of
> the pool. (the registration is done on asterisk server)
>
> The OpenSIPS configuration routing part is:
>
> route{
>
> 	if (!mf_process_maxfwd_header("10")) {
> 		sl_send_reply("483","Too Many Hops");
> 		exit;
> 	}
>
> 	xlog("SIP route info: [$fu/$tu/$ru/$ci]");
> 	xlog("SIP method: $rm");
>
> 	if (!has_totag()) {
> 		# initial request
> 		record_route();
> 	}
> 	else {
> 		# sequential request - obey the indicated route
> 		loose_route();
> 		t_relay();
> 		exit;
> 	}
>
> 	# CANCEL processing
> 	if (is_method("CANCEL"))
> 	{
> 		if (t_check_trans())
> 			t_relay();
> 		exit;
> 	}
>
> 	if (is_method("OPTIONS")) {
> 		t_relay();
> 		xlog("OPTIONS for: [$fu/$tu/$ru/$ci]");
> 		exit;
> 	}
>
> 	# from now on we have only the initial request
> 	# select the node that'll handle the call
> 	# different method is used for INVITE/REGISTER requests
> 	# unknown methods are rejected here
>
> 	xlog("First route:
> [USER:$au/CALL-ID:$ci/FROM-TAG:$ft/FROM-URI:$fu/FROM-URI-USER:$fU/METHOD:$rm]");
>
> 	if (is_method("INVITE")) {
> 		if (!ds_select_dst("1", "5")) {
> 			xlog("Service unavailable for ds_select_dst[INVITE]");
> 			send_reply("503","Service Unavailable");
> 			exit;
> 		}
> 	}
> 	else if (is_method("REGISTER")) {
> 		if (!ds_select_dst("1", "5")) {
> 			xlog("Service unavailable for ds_select_dst[REGISTER]");
> 			send_reply("503","Service Unavailable");
> 			exit;
> 		}
> 	}
> 	else {
> 		send_reply("405","Method Not Allowed");
> 		exit;
> 	}
>
> 	# route the request
> 	if (!t_relay()) {
> 		sl_reply_error();
> 	}
> }
>
>
> the dispatcher.list is simple:
> 1 sip:192.168.6.131:5060
>
>
> the registration part, on asterisk seems OK (I think), but for every
> SIP phone in 'sip show peers' I saw only the openSIPS IP address:
> Name/username              Host            Dyn Nat ACL Port     Status
> 2001/2001                  192.168.6.130    D   N      5060     OK (1342 ms)
> 2002/2002                  192.168.6.130    D   N      5060     OK (1403 ms)
>
> My asterisk dialplan is simple:
> exten =>  101,1,Answer()
> exten =>  101,n,Playback(demo-congrats)
> exten =>  101,n,Hangup()
>
> exten =>  _XXXX,2,NoOp(internal context called on Server A to ${EXTEN},
> CALLERID_num ${CALLERID(num)}, CALLERID_num_f2 ${CALLERID(num):0:2})
> exten =>  _XXXX,3,Dial(SIP/${EXTEN},15)
>
>
> when, from phone 2001 or 2002 I place a call to 101 everything works
> fine, but when I call 2001 from 2002 (and vice-versa) I can't place
> the call, and in asterisk log I found:
>
>      -- Executing [2002 at internal:1] NoOp("SIP/2001-0000000f", "2002")
> in new stack
>      -- Executing [2002 at internal:2] NoOp("SIP/2001-0000000f", "internal
> context called on Server A to 2002, CALLERID_num 2001, CALLERID_num_f2
> 20") in new stack
>      -- Executing [2002 at internal:3] Dial("SIP/2001-0000000f",
> "SIP/2002,15") in new stack
>    == Using SIP RTP CoS mark 5
>      -- Called 2002
>      -- Got SIP response 482 "Loop Detected" back from 192.168.6.130
>      -- Now forwarding SIP/2001-0000000f to 'Local/2002 at internal'
> (thanks to SIP/2002-00000010)
>      -- Executing [2002 at internal:1] NoOp("Local/2002 at internal-187c;2",
> "2002") in new stack
>      -- Executing [2002 at internal:2] NoOp("Local/2002 at internal-187c;2",
> "internal context called on Server A to 2002, CALLERID_num 2001,
> CALLERID_num_f2 20") in new stack
>      -- Executing [2002 at internal:3] Dial("Local/2002 at internal-187c;2",
> "SIP/2002,15") in new stack
>    == Spawn extension (internal, 2002, 3) exited non-zero on
> 'Local/2002 at internal-187c;2'
>    == Everyone is busy/congested at this time (1:0/0/1)
>      -- Executing [2002 at internal:4] Hangup("SIP/2001-0000000f", "") in new stack
>    == Spawn extension (internal, 2002, 4) exited non-zero on 'SIP/2001-0000000f'
>
> Could you please give me some hints on where I am wrong?
> registering directly on asterisk box, bypassing OpenSIPS, the call
> works correctly.
>
> thanks so much
>    



More information about the Users mailing list