[prev in list] [next in list] [prev in thread] [next in thread]
List: openser-users
Subject: Re: [SR-Users] REGISTER with http_async_client ?
From: Federico Cabiddu <federico.cabiddu () gmail ! com>
Date: 2022-01-31 17:55:55
Message-ID: CAFOaF_htOYLyo+oG3J5Pum3GXP--9iqzA8+xDxBmo2Cm+CtYgw () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi Cyril,
it is normal that the callback route is considered a failure route, this is
the internal behavior of transaction suspension/resume as implemented by
the tm module.
Are you sure that there is no other SIP message interfering with your flow?
Could you set kamailio loglevel to 3 to see what happens?
Cheers,
Federico
On Mon, Jan 31, 2022 at 10:41 AM Cyril Ramière <cyril.ramiere@gmail.com>
wrote:
> Hi Frederico,
>
> (sorry for the double posting today, despite telling gmail to not put
> messages from this mailing il the spam folder, it has done it again :/ )
>
> Thanks for your reply, I tried your suggestion and sadly it has
> not worked, I still have the same error.
> Upon searching and digging through the logs I still can't understand why
> after the http client is doing it's request, the debugger shows that we are
> not in "request" route but in "failure" route instead, I don't know if this
> is a consequence or a symptom of the issue.
>
> I triple checked my mock api, it returns a http 200 and sees the request
> made by the http client.
>
> Cheers
>
> Le jeu. 27 janv. 2022 Ã 16:17, Federico Cabiddu <
> federico.cabiddu@gmail.com> a écrit :
>
>> Hi,
>> I'm running a scenario very similar to yours with kamailio 5.5.3 and I
>> have no issue.
>> The only difference with your scenario is that I don't do the challenge
>> with the client, I always reply 403 and release the transaction after.
>> I didn't have the time to replicate your exact scenario but it could be
>> worth trying to add a t_release() after the www_challenge().
>>
>> Cheers,
>>
>> Federico
>>
>> On Thu, Jan 27, 2022 at 8:04 AM Cyril Ramière <cyril.ramiere@gmail.com>
>> wrote:
>>
>>> Hi there,
>>>
>>> I have a weird issue with kamailio (latest docker
>>> image kamailio-ci:5.5.2-alpine) and http_async_client.
>>>
>>> Before posting a lot of logs, let me describe what I want to achieve.
>>>
>>> I have a Kamailio and a SIP Phone.
>>>
>>> The SIP phone sends a REGISTER to kamailio, then in my routing block, I
>>> check if I have an Authorization header.
>>>
>>> Since I don't have an Authorization (first message), I
>>> use "www_challenge()".
>>> This replies to the SIP phone, and then the SIP phone sends a new
>>> REGISTER with the correct Authorization header.
>>>
>>> So far so good.
>>>
>>> Now, when I get the REGISTER with Authorization header, I want to ask an
>>> HTTP endpoint if this user is allowed to connect and check the password
>>> using http_async_query().
>>>
>>> The problem is that when the transaction resumes, the tmx module is
>>> unhappy and throws this error :
>>>
>>> 30(36) CRITICAL: tmx [t_var.c:546]: pv_get_tm_reply_code(): no picked
>>> branch (-1) for a final response in MODE_ONFAILURE
>>>
>>> And a 500 error is sent back to the sip phone.
>>> The AUTH_REPLY route is still called and I can use the $http* values.
>>>
>>> Do you see something that I am doing wrong or missing in my logic?
>>> Is pausing/resuming to use the async http client is allowed if I'm
>>> handling a REGISTER transaction?
>>>
>>> Here's a simplified version of my routing block (not far from reality):
>>>
>>> ##### SNIP
>>>
>>> request_route{
>>>
>>> route(AUTH);
>>>
>>>
>>> route[AUTH]{
>>>
>>> if (is_method("REGISTER"){
>>>
>>> if(no_auth_header){
>>>
>>> www_challenge("$td","1");
>>>
>>> exit;
>>>
>>> }
>>>
>>> else{
>>>
>>> t_newtran();
>>>
>>> http_async_query("http://xxx.xxx.xxx.xxx:9000/auth?foo=bar", "AUTH_REPLY");
>>>
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>>
>>> route[AUTH_REPLY]{
>>>
>>> xlog("L_INFO", "route[HTTP_REPLY]: status $http_rs\n");
>>>
>>> }
>>>
>>>
>>> }
>>>
>>> ##### END SNIP
>>>
>>>
>>> Best regards!
>>> __________________________________________________________
>>> Kamailio - Users Mailing List - Non Commercial Discussions
>>> * sr-users@lists.kamailio.org
>>> Important: keep the mailing list in the recipients, do not reply only to
>>> the sender!
>>> Edit mailing list options or unsubscribe:
>>> * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>
>> __________________________________________________________
>> Kamailio - Users Mailing List - Non Commercial Discussions
>> * sr-users@lists.kamailio.org
>> Important: keep the mailing list in the recipients, do not reply only to
>> the sender!
>> Edit mailing list options or unsubscribe:
>> * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions
> * sr-users@lists.kamailio.org
> Important: keep the mailing list in the recipients, do not reply only to
> the sender!
> Edit mailing list options or unsubscribe:
> * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
[Attachment #5 (text/html)]
<div dir="ltr">Hi Cyril,<div>it is normal that the callback route is considered a \
failure route, this is the internal behavior of transaction suspension/resume as \
implemented by the tm module.</div><div>Are you sure that there is no other SIP \
message interfering with your flow?</div><div>Could you set kamailio loglevel to 3 \
to see what happens?</div><div><br></div><div>Cheers,</div><div><br></div><div>Federico</div></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 31, 2022 at 10:41 \
AM Cyril Ramière <<a \
href="mailto:cyril.ramiere@gmail.com">cyril.ramiere@gmail.com</a>> \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi \
Frederico, <div><br></div><div>(sorry for the double posting today, despite telling \
gmail to not put messages from this mailing il the spam folder, it has done it again \
:/ ) </div><div><br></div><div>Thanks for your reply, I tried your suggestion and \
sadly it has not worked, I still have the same error.</div><div>Upon searching and \
digging through the logs I still can't understand why after the http client is \
doing it's request, the debugger shows that we are not in "request" \
route but in "failure" route instead, I don't know if this is a \
consequence or a symptom of the issue.</div><div><br></div><div>I triple checked my \
mock api, it returns a http 200 and sees the request made by the http \
client.</div><div><br></div><div>Cheers</div></div><br><div class="gmail_quote"><div \
dir="ltr" class="gmail_attr">Le jeu. 27 janv. 2022 Ã 16:17, Federico Cabiddu \
<<a href="mailto:federico.cabiddu@gmail.com" \
target="_blank">federico.cabiddu@gmail.com</a>> a écrit :<br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div>I'm running a scenario \
very similar to yours with kamailio 5.5.3 and I have no issue. </div><div>The only \
difference with your scenario is that I don't do the challenge with the client, I \
always reply 403 and release the transaction after.</div><div>I didn't have the \
time to replicate your exact scenario but it could be worth trying to add a \
t_release() after the \
www_challenge().</div><div><br></div><div>Cheers,</div><div><br></div><div>Federico \
</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, \
Jan 27, 2022 at 8:04 AM Cyril Ramière <<a href="mailto:cyril.ramiere@gmail.com" \
target="_blank">cyril.ramiere@gmail.com</a>> wrote:<br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi there,<div><br></div><div>I have \
a weird issue with kamailio (latest docker image kamailio-ci:5.5.2-alpine) and \
http_async_client.</div><div><br></div><div>Before posting a lot of logs, let me \
describe what I want to achieve.</div><div><br></div><div>I have a Kamailio and a SIP \
Phone.</div><div><br></div><div>The SIP phone sends a REGISTER to kamailio, then in \
my routing block, I check if I have an Authorization \
header.</div><div><br></div><div>Since I don't have an Authorization (first \
message), I use "www_challenge()".</div><div>This replies to the SIP \
phone, and then the SIP phone sends a new REGISTER with the correct Authorization \
header.</div><div><br></div><div>So far so good.</div><div><br></div><div>Now, when I \
get the REGISTER with Authorization header, I want to ask an HTTP endpoint if this \
user is allowed to connect and check the password using \
http_async_query().</div><div><br></div><div>The problem is that when the transaction \
resumes, the tmx module is unhappy and throws this error :</div><div><br></div><div>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Andale \
Mono";color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span \
style="font-variant-ligatures:no-common-ligatures">30(36) CRITICAL: tmx \
[t_var.c:546]: pv_get_tm_reply_code(): no picked branch (-1) for a final response in \
MODE_ONFAILURE</span></p></div><div><br></div><div>And a 500 error is sent back to \
the sip phone.</div><div>The AUTH_REPLY route is still called and I can use the \
$http* values.</div><div><br></div><div>Do you see something that I am doing wrong or \
missing in my logic?</div><div>Is pausing/resuming to use the async http client is \
allowed if I'm handling a REGISTER \
transaction?</div><div><br></div><div>Here's a simplified version of my routing \
block (not far from reality):</div><div><br></div><div>##### SNIP \
</div><div><br></div><div><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace">request_route{</pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace">route(AUTH);</pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace"><br></pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace">route[AUTH]{</pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace"><pre \
style="font-family:Menlo,monospace"> if (is_method(<span \
style="color:rgb(3,47,98)">"REGISTER"</span>){</pre><pre \
style="font-family:Menlo,monospace"> if(no_auth_header){</pre><pre \
style="font-family:Menlo,monospace"> www_challenge(<span \
style="color:rgb(3,47,98)">"$td"</span>,<span \
style="color:rgb(3,47,98)">"1"</span>)<span \
style="color:rgb(106,115,125)">;</span></pre><pre \
style="font-family:Menlo,monospace"><span style="color:rgb(106,115,125)"> \
exit;</span></pre><pre style="font-family:Menlo,monospace"> }</pre><pre \
style="font-family:Menlo,monospace"> else{</pre><pre \
style="font-family:Menlo,monospace"> t_newtran();</pre><pre \
style="font-family:Menlo,monospace"> http_async_query(<span \
style="color:rgb(3,47,98)">"<a href="http://xxx.xxx.xxx.xxx:9000/auth?foo=bar" \
target="_blank">http://xxx.xxx.xxx.xxx:9000/auth?foo=bar</a>"</span>, <span \
style="color:rgb(3,47,98)">"AUTH_REPLY"</span>)<span \
style="color:rgb(106,115,125)">;</span></pre><pre \
style="font-family:Menlo,monospace"> }</pre><pre \
style="font-family:Menlo,monospace"> }</pre></pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace">}</pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace"><br></pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace">route[AUTH_REPLY]{</pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace"> xlog(<span \
style="color:rgb(3,47,98)">"L_INFO"</span>, <span \
style="color:rgb(3,47,98)">"route[HTTP_REPLY]: status \
$http_rs\n"</span>)<span style="color:rgb(106,115,125)">;</span><br></pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace">}</pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace"><br></pre><pre \
style="color:rgb(36,41,46);font-family:Menlo,monospace">}</pre></div><div>##### END \
SNIP</div><div><br></div><div><br></div><div>Best regards!</div>
</div>
__________________________________________________________<br>
Kamailio - Users Mailing List - Non Commercial Discussions<br>
* <a href="mailto:sr-users@lists.kamailio.org" \
target="_blank">sr-users@lists.kamailio.org</a><br>
Important: keep the mailing list in the recipients, do not reply only to the \
sender!<br> Edit mailing list options or unsubscribe:<br>
* <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" \
rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div>
__________________________________________________________<br>
Kamailio - Users Mailing List - Non Commercial Discussions<br>
* <a href="mailto:sr-users@lists.kamailio.org" \
target="_blank">sr-users@lists.kamailio.org</a><br>
Important: keep the mailing list in the recipients, do not reply only to the \
sender!<br> Edit mailing list options or unsubscribe:<br>
* <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" \
rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div>
__________________________________________________________<br>
Kamailio - Users Mailing List - Non Commercial Discussions<br>
* <a href="mailto:sr-users@lists.kamailio.org" \
target="_blank">sr-users@lists.kamailio.org</a><br>
Important: keep the mailing list in the recipients, do not reply only to the \
sender!<br> Edit mailing list options or unsubscribe:<br>
* <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" \
rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div>
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
* sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
* https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic