Hi everybody, I'm using Opeser as Proxy and one Asterisk as Gateway and Voicemail server. Suppose that an incoming calls arrives to Ser from Asterisk and the user is offline; Then Openser sends back the Invite to Asterisk that should activate the voicemail application but unfortunately it detects a Loop (482) and rejects the invite. I think I have to mangle the SIP message in Openser before the send to Asterisk again. This is what I currently do:
if(!lookup("location")) { #send to voicemail if active but not registerd xlog("L_INFO", "Local user offline - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); if($avp(s:vmail) == "1") { route(11); } else { route(20); } } else { xlog("L_INFO", "Local user online - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); route(9); } exit;
....
route[11] { xlog("L_INFO", "Forwarding request to VM\n"); prefix("vm"); sethostport("asterisk-gw:5060"); #append_branch(); if (!t_relay()) { xlog("L_INFO", "Unable TO Forward the request to VM\n"); route(20); exit; }
What can I do to avoid Loop Detection?
Thanks in advance,
Cosimo Fadda ___________
El Thursday 03 April 2008 07:50:17 Cosimo Fadda escribió:
Hi everybody, I'm using Opeser as Proxy and one Asterisk as Gateway and Voicemail server. Suppose that an incoming calls arrives to Ser from Asterisk and the user is offline; Then Openser sends back the Invite to Asterisk that should activate the voicemail application but unfortunately it detects a Loop (482) and rejects the invite. I think I have to mangle the SIP message in Openser before the send to Asterisk again.
Asterisk FAILS detecting loop-back since your case is NOT a loop-back. There is a patch to solve it but it's stopped. Anyway I tryed it with a concrete SVN version and it works:
http://bugs.digium.com/view.php?id=7403
Also, I wrote (in Spanish) how to apply it: http://blog.aliax.net/2007/08/asterisk-parche-chansip-para-permitir.html
On 04/03/08 11:37, Iñaki Baz Castillo wrote:
El Thursday 03 April 2008 07:50:17 Cosimo Fadda escribió:
Hi everybody, I'm using Opeser as Proxy and one Asterisk as Gateway and Voicemail server. Suppose that an incoming calls arrives to Ser from Asterisk and the user is offline; Then Openser sends back the Invite to Asterisk that should activate the voicemail application but unfortunately it detects a Loop (482) and rejects the invite. I think I have to mangle the SIP message in Openser before the send to Asterisk again.
Asterisk FAILS detecting loop-back since your case is NOT a loop-back. There is a patch to solve it but it's stopped. Anyway I tryed it with a concrete SVN version and it works:
Is is working out of the box with the SVN version? Or the patch have to be applied to SVN? I have been interested in this patch, but lost the row of events over the time ...
Thanks, Daniel
Also, I wrote (in Spanish) how to apply it: http://blog.aliax.net/2007/08/asterisk-parche-chansip-para-permitir.html
El Thursday 03 April 2008 09:21:31 Daniel-Constantin Mierla escribió:
Asterisk FAILS detecting loop-back since your case is NOT a loop-back. There is a patch to solve it but it's stopped. Anyway I tryed it with a concrete SVN version and it works:
Is is working out of the box with the SVN version? Or the patch have to be applied to SVN? I have been interested in this patch, but lost the row of events over the time ...
AFAIK it's not included in the trunk version at all. There is just a patch working wiht a specific SVN version. Some time ago I tried to apply that patch to the current svn version and I couldn't apply it because important changes in chan_sip.c and Asterisk code (BTW I didn't spend too much time trying it).
Best regards.
Iñaki Baz Castillo ha scritto:
El Thursday 03 April 2008 07:50:17 Cosimo Fadda escribió:
Hi everybody, I'm using Opeser as Proxy and one Asterisk as Gateway and Voicemail server. Suppose that an incoming calls arrives to Ser from Asterisk and the user is offline; Then Openser sends back the Invite to Asterisk that should activate the voicemail application but unfortunately it detects a Loop (482) and rejects the invite. I think I have to mangle the SIP message in Openser before the send to Asterisk again.
Asterisk FAILS detecting loop-back since your case is NOT a loop-back. There is a patch to solve it but it's stopped. Anyway I tryed it with a concrete SVN version and it works:
http://bugs.digium.com/view.php?id=7403
Also, I wrote (in Spanish) how to apply it: http://blog.aliax.net/2007/08/asterisk-parche-chansip-para-permitir.html
I'll have a look to the patch, even if I can't apply it to a running system..
Juha Heinanen ha scritto: Cosimo Fadda writes:
Then Openser sends back the Invite to Asterisk that should activate the voicemail application but
how about sending back 302 to voicemail uri.
-- juha
My first thought was to send a 302 from Openser to Asterisk, but I don't know how..
Thanks everybody,
Cosimo Fadda _______________
El Thursday 03 April 2008 10:49:19 Juha Heinanen escribió:
Cosimo Fadda writes:
My first thought was to send a 302 from Openser to Asterisk, but I don't know how..
try rewriting the uri and then calling sl_send_reply("302", "Moved Temporalily").
And add the mandatory "Contact" header with the URI of the voicemail URI (I don't remember the function adding headers to the reply but it does exist).
On 04/03/08 13:50, Iñaki Baz Castillo wrote:
El Thursday 03 April 2008 10:49:19 Juha Heinanen escribió:
Cosimo Fadda writes:
My first thought was to send a 302 from Openser to Asterisk, but I don't know how..
try rewriting the uri and then calling sl_send_reply("302", "Moved Temporalily").
And add the mandatory "Contact" header with the URI of the voicemail URI (I don't remember the function adding headers to the reply but it does exist).
append_to_reply(...) in textops module
http://www.openser.org/docs/modules/1.3.x/textops.html#AEN276
Cheers, Daniel
Thank you everybody, I'll try it immediatly!
Regards,
Cosimo
OT: Greetings to Daniel from Dario Busso
Daniel-Constantin Mierla ha scritto:
On 04/03/08 13:50, Iñaki Baz Castillo wrote:
El Thursday 03 April 2008 10:49:19 Juha Heinanen escribió:
Cosimo Fadda writes:
My first thought was to send a 302 from Openser to Asterisk, but I don't know how..
try rewriting the uri and then calling sl_send_reply("302", "Moved Temporalily").
And add the mandatory "Contact" header with the URI of the voicemail URI (I don't remember the function adding headers to the reply but it does exist).
append_to_reply(...) in textops module
http://www.openser.org/docs/modules/1.3.x/textops.html#AEN276
Cheers, Daniel
Hi everybody, thanks to your tips now the voicemail route works without loop detection from asterisk; But maybe I'm still making some little mistake: this is the route I'm using:
route[11] { xlog("L_INFO", "Forwarding request to VM\n"); #remove_hf("Contact"); append_to_reply("Contact: sip:vm$rU@asteriskgw"); remove_hf("Contact"); sl_send_reply("302", "Moved Temporalily "); exit;
}
I've tried both removing the original "Contact" before and after the append, but I always have this 302 Message:
<-- SIP read from OPENSERIP:5060: SIP/2.0 302 Moved Temporalily Via: SIP/2.0/UDP asteriskgw:5060;branch=z9hG4bK1262b98d;rport=5060 From: "0MXXXXXX" sip:0MXXXXX@asteriskgw;tag=as13654251 To: sip:cosimo@OPENSERIP;tag=26501d74ed63701b338d7e605938b7cb.11ac Call-ID: 52e6481a1dd8674c559c477c36558c19@asteriskgw CSeq: 102 INVITE Contact: sip:vmcosimo@asteriskgwContact: sip:cosimo@OPENSERIP Server: OpenSER (1.3.1-notls (i386/linux)) Content-Length: 0
There are two Contact headers!! This is not a problem for me since Asterisk ignore the second, but I'd like to avoid this behavior.. Maybe I have to rewrite the contact without appending another one. Thanks in advance,
Cosimo
Cosimo Fadda ha scritto:
Thank you everybody, I'll try it immediatly!
Regards,
Cosimo
OT: Greetings to Daniel from Dario Busso
Daniel-Constantin Mierla ha scritto:
On 04/03/08 13:50, Iñaki Baz Castillo wrote:
El Thursday 03 April 2008 10:49:19 Juha Heinanen escribió:
Cosimo Fadda writes:
My first thought was to send a 302 from Openser to Asterisk, but I don't know how..
try rewriting the uri and then calling sl_send_reply("302", "Moved Temporalily").
And add the mandatory "Contact" header with the URI of the voicemail URI (I don't remember the function adding headers to the reply but it does exist).
append_to_reply(...) in textops module
http://www.openser.org/docs/modules/1.3.x/textops.html#AEN276
Cheers, Daniel
____________________
El Friday 04 April 2008 09:24:21 Cosimo Fadda escribió:
There are two Contact headers!! This is not a problem for me since Asterisk ignore the second, but I'd like to avoid this behavior.. Maybe I have to rewrite the contact without appending another one.
Opsss, that's an issue yes!
Sincerely, I think is not possible to avoid it since it's created by OpenSer when creating the response :(
El Friday 04 April 2008 12:21:12 Juha Heinanen escribió:
Cosimo Fadda writes:
But maybe I'm still making some little mistake: this is the route I'm using:
did you try my proposal? i said to call rewrite_uri and then sl_send_reply. i didn't say anything about manipulating contact header.
You said:
"try rewriting the uri and then calling sl_send_reply("302", "Moved Temporalily")."
Do you mean that if OpenSer receives a request, changes the RURI and isntead of forwarding the request creates a reply "302" then the Contact header will be the new RURI? Why it shouldn't work?
Iñaki Baz Castillo writes:
Do you mean that if OpenSer receives a request, changes the RURI and isntead of forwarding the request creates a reply "302" then the Contact header will be the new RURI? Why it shouldn't work?
all i tried to say is that rewriting request uri (using rewrite_uri or by some other means) and then calling sl_send_reply("302", "Moved Temporalily") might work. have you tried and it does not work for you?
-- juha
El Friday 04 April 2008 13:22:42 Juha Heinanen escribió:
Iñaki Baz Castillo writes:
Do you mean that if OpenSer receives a request, changes the RURI and isntead of forwarding the request creates a reply "302" then the Contact header will be the new RURI? Why it shouldn't work?
all i tried to say is that rewriting request uri (using rewrite_uri or by some other means) and then calling sl_send_reply("302", "Moved Temporalily") might work.
Sorry Juha, my question should be: "Why it should work?" since I can't understand how rewriting the RURI and sending a 302 can generate the reply with "Contact = new RURI". I've never read doc aobut doing it.
have you tried and it does not work for you?
No, I haven't tryed, but it seems to work as Cosimo has replied, so you are completely right ;)
Iñaki Baz Castillo writes:
"Why it should work?" since I can't understand how rewriting the RURI and sending a 302 can generate the reply with "Contact = new RURI". I've never read doc aobut doing it.
indeed, it is not documented in sl/README. you could issue a tracker request on it.
-- juha
Hi,
Here is an example ;)
http://openser.svn.sourceforge.net/viewvc/openser/trunk/examples/redirect.cf...
Regards, Bogdan
Juha Heinanen wrote:
Iñaki Baz Castillo writes:
"Why it should work?" since I can't understand how rewriting the RURI and sending a 302 can generate the reply with "Contact = new RURI". I've never read doc aobut doing it.
indeed, it is not documented in sl/README. you could issue a tracker request on it.
-- juha
Users mailing list Users@lists.openser.org http://lists.openser.org/cgi-bin/mailman/listinfo/users
Hi everybody and thank you for your interest,
Juha Heinanen ha scritto:
Cosimo Fadda writes:
But maybe I'm still making some little mistake: this is the route I'm using:
did you try my proposal? i said to call rewrite_uri and then sl_send_reply. i didn't say anything about manipulating contact header.
I finally followed your proposal and now it works,
route[11] { xlog("L_INFO", "Forwarding request to VM\n"); prefix("vm"); rewritehost("asteriskgw"); sl_send_reply("302", "Moved Temporalily "); exit; }
<-- SIP read from openser:5060: SIP/2.0 302 Moved Temporalily Via: SIP/2.0/UDP 217.199.19.212:5060;branch=z9hG4bK5f777042;rport=5060 From: "0MXXXXXX" sip:0MXXXXXX@asteriskgw;tag=as1c030a33 To: sip:matteo@openser;tag=26501d74ed63701b338d7e605938b7cb.54a5 Call-ID: 7eb5e5ea03c57c900b45052c28701977@asteriskgw CSeq: 102 INVITE Contact: sip:vmmatteo@asteriskgw Server: OpenSER (1.3.1-notls (i386/linux)) Content-Length: 0
Iñaki Baz Castillo ha scritto:
El Friday 04 April 2008 12:21:12 Juha Heinanen escribió:
Cosimo Fadda writes:
But maybe I'm still making some little mistake: this is the route I'm using:
did you try my proposal? i said to call rewrite_uri and then sl_send_reply. i didn't say anything about manipulating contact header.
You said:
"try rewriting the uri and then calling sl_send_reply("302", "Moved Temporalily")."
Do you mean that if OpenSer receives a request, changes the RURI and isntead of forwarding the request creates a reply "302" then the Contact header will be the new RURI? Why it shouldn't work?
I haven't found anything in the docs about this.
Thank you again,
Regards,
Cosimo ____________
Here is how I solve this.
In Asterisk, I add a SIP header just before sending it to OpenSER using the function: SipAddHeader(P-hint: From Asterisk).
Then, in OpenSER I have the following:
# check to see if user is online if (!lookup("location")) { # SIP from Asterisk or not a call attempt if (search("(P-hint):.From Asterisk") || !(method==INVITE)) { sl_send_reply("480","User Temporarily Unavailable"); exit; } else { route(2); exit; }; };
route[2] { # Let Asterisk deal with voicemail/forward sl_send_reply("181", "Forward to Voicemail"); prefix("vm"); setflag(9); # forward to Asterisk route(1); }
On Thu, Apr 3, 2008 at 12:50 AM, Cosimo Fadda cosimo.fadda@klarya.it wrote:
Hi everybody, I'm using Opeser as Proxy and one Asterisk as Gateway and Voicemail server. Suppose that an incoming calls arrives to Ser from Asterisk and the user is offline; Then Openser sends back the Invite to Asterisk that should activate the voicemail application but unfortunately it detects a Loop (482) and rejects the invite. I think I have to mangle the SIP message in Openser before the send to Asterisk again. This is what I currently do:
if(!lookup("location")) { #send to voicemail if active but not registerd xlog("L_INFO", "Local user offline - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); if($avp(s:vmail) == "1") { route(11); } else { route(20); } } else { xlog("L_INFO", "Local user online - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); route(9); } exit;
....
route[11] { xlog("L_INFO", "Forwarding request to VM\n"); prefix("vm"); sethostport("asterisk-gw:5060"); #append_branch(); if (!t_relay()) { xlog("L_INFO", "Unable TO Forward the request to VM\n"); route(20); exit; }
What can I do to avoid Loop Detection?
Thanks in advance,
Cosimo Fadda ___________
Users mailing list Users@lists.openser.org http://lists.openser.org/cgi-bin/mailman/listinfo/users
El Thursday 10 April 2008 23:00:28 Adrian A escribió:
Here is how I solve this.
In Asterisk, I add a SIP header just before sending it to OpenSER using the function: SipAddHeader(P-hint: From Asterisk).
Then, in OpenSER I have the following:
# check to see if user is online if (!lookup("location")) { # SIP from Asterisk or not a call attempt if (search("(P-hint):.From Asterisk") || !(method==INVITE)) { sl_send_reply("480","User Temporarily Unavailable"); exit; } else { route(2); exit; }; };
route[2] { # Let Asterisk deal with voicemail/forward sl_send_reply("181", "Forward to Voicemail"); prefix("vm"); setflag(9); # forward to Asterisk route(1); }
I can't understand why that should work, in fact Asterisk is receiving the same INVITE he sent (well, RURI modified but the Asterisk bug is that it doesn't recogniza a spiral).
If the INVITE comes in from Asterisk, OpenSER replies with 480 and lets Asterisk deal with sending call to voicemail (e.g. dialstatus = unavailable). This eliminates the loop because the INVITE does not come back to Asterisk.
On Fri, Apr 11, 2008 at 12:33 AM, Iñaki Baz Castillo ibc@in.ilimit.es wrote:
El Thursday 10 April 2008 23:00:28 Adrian A escribió:
Here is how I solve this.
In Asterisk, I add a SIP header just before sending it to OpenSER using
the
function: SipAddHeader(P-hint: From Asterisk).
Then, in OpenSER I have the following:
# check to see if user is online if (!lookup("location")) { # SIP from Asterisk or not a call attempt if (search("(P-hint):.From Asterisk") ||
!(method==INVITE)) { sl_send_reply("480","User Temporarily
Unavailable");
exit; } else { route(2); exit; }; };
route[2] { # Let Asterisk deal with voicemail/forward sl_send_reply("181", "Forward to Voicemail"); prefix("vm"); setflag(9); # forward to Asterisk route(1); }
I can't understand why that should work, in fact Asterisk is receiving the same INVITE he sent (well, RURI modified but the Asterisk bug is that it doesn't recogniza a spiral).
-- Iñaki Baz Castillo ibc@in.ilimit.es _______________________________________________ Users mailing list Users@lists.openser.org http://lists.openser.org/cgi-bin/mailman/listinfo/users
2008/4/12, Adrian A adrianvoip@gmail.com:
If the INVITE comes in from Asterisk, OpenSER replies with 480 and lets Asterisk deal with sending call to voicemail (e.g. dialstatus = unavailable). This eliminates the loop because the INVITE does not come back to Asterisk.
Ok ok, I understand what you mean. But that is just useful for redirection to voicemail and so. For example, imagine you have Asterisk as PSTN gateway. Imagine Asterisk receives a call from PSTN and routes it to OpenSer, and OpenSer destination user has a redirection to a mobile number. Then OpenSer would route the invite back to Asterisk who will detect a loop (an spiral in fact, but Asterisk is buggy here).
Regards.
On Apr 12, 2008, at 1:59 AM, Iñaki Baz Castillo wrote:
Ok ok, I understand what you mean. But that is just useful for redirection to voicemail and so. For example, imagine you have Asterisk as PSTN gateway. Imagine Asterisk receives a call from PSTN and routes it to OpenSer, and OpenSer destination user has a redirection to a mobile number. Then OpenSer would route the invite back to Asterisk who will detect a loop (an spiral in fact, but Asterisk is buggy here).
What we've been doing for the last 4 years in this is that OpenSER never, ever replies back to Asterisk with the same INVITE message. Asterisk has all the redirection intelligence. When OpenSER detects that a user is offline it replies with some 4xx error message, Asterisk detects that, goes "ooh, user is offline, let's see what i have to do in this case" and does it's thing. Unfortunately we've never had the opportunity to handle the cases where the users UA or OpenSER replies back with a 3xx type message to tell Asterisk where to redirect to. That might have something to do with us being a little strange though.
OpenSER never, ever replies back to Asterisk with the same INVITE message. Asterisk has all the redirection intelligence
That's the point. I meant an Asterisk without routing intelligent, just as media server or gateway.
Regards.
That's what the call forwarding in SIP UAs use to "forward" a call to another destination, 302 redirect messages. It works fine with Asterisk. Unless you need openser to handle accounting or such, redirects would be a valid option.
Mike
-----Original Message----- From: users-bounces@lists.openser.org [mailto:users-bounces@lists.openser.org] On Behalf Of Andreas Sikkema Sent: Saturday, April 12, 2008 1:05 AM To: users@lists.openser.org Subject: Re: [OpenSER-Users] Avoid Loops between Openser and Asterisk
Unfortunately we've never had the opportunity to handle the cases where the users UA or OpenSER replies back with a 3xx type message to tell Asterisk where to redirect to. That might have something to do with us being a little strange though.
Hi everybody,
Andreas Sikkema ha scritto
Asterisk has all the redirection intelligence. When OpenSER detects that a user is offline it replies with some 4xx error message, Asterisk detects that, goes "ooh, user is offline, let's see what i have to do in this case" and does it's thing.
Not very sure that Asterisk has all the redirection intelligence, in particular if the SIP users are not registered on Asterisk the variable Dialstatus gives you the 'state' of the proxy rather than the user; I mean there is a difference between this two cases: Dial(SIP/alice,,) Dial(SIP/PROXY-1/alice,,} where in the first case alice is registered with Asterisk, in the second is regisered with Proxy-1. Dial() returns DIALSTATUS=CONGESTION for pretty much every call setup problem; there is also no way to look at a SIP response in the dialplan, even though you can see every other SIP header with ${SIP_HEADER(<header_name>) you cannot see and treat accordingly the actual response code. So, in my opinion is better to put the intelligence on Openser rather than on Asterisk,
Regards,
Cosimo ____________________