<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 2 Feb 2022, at 23:58, Cyril Ramière <<a href="mailto:cyril.ramiere@gmail.com" class="">cyril.ramiere@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class="">Hi Karsten,<div class=""><br class=""></div><div class="">Thanks for the clue, unfortunately I can't use this module because the clients are "dumb" sip phones.</div><div class=""><br class=""></div><div class="">The goal of my implementation is to use our application API to handle the login.</div><div class=""><br class=""></div><div class="">The plan was that a sip phone sends a REGISTER, I ask the API endpoint if this user/password is ok to connect and allow/deny based on the reply and informations provided by the API.</div><div class=""><br class=""></div><div class="">Everything is relying on the fact that I can make my HTTP call when handling the REGISTER, sadly for me, it doesn't work and I still can't figure why.</div></div></div></div></blockquote>Try http_client. I’ve used it a lot of time for authentication. It will block your thread while waiting for response, but you can handle some of those issues by caching secrets for a short time with htable.</div><div><br class=""></div><div>/O<br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">Cyril</div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 2 févr. 2022 à 19:49, Karsten Horsmann <<a href="mailto:khorsmann@gmail.com" class="">khorsmann@gmail.com</a>> a écrit :<br class=""></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="auto" class="">Hi Cyril,<div dir="auto" class=""><br class=""></div><div dir="auto" class="">This Kamailio module could imho do the same </div><div dir="auto" class=""><br class=""></div><div dir="auto" class=""><a href="https://www.kamailio.org/docs/modules/devel/modules/auth_ephemeral.html" target="_blank" class="">https://www.kamailio.org/docs/modules/devel/modules/auth_ephemeral.html</a><br class=""></div><div dir="auto" class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Cyril Ramière <<a href="mailto:cyril.ramiere@gmail.com" target="_blank" class="">cyril.ramiere@gmail.com</a>> schrieb am Do., 27. Jan. 2022, 08:04:<br class=""></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" class="">Hi there,<div class=""><br class=""></div><div class="">I have a weird issue with kamailio (latest docker image kamailio-ci:5.5.2-alpine) and http_async_client.</div><div class=""><br class=""></div><div class="">Before posting a lot of logs, let me describe what I want to achieve.</div><div class=""><br class=""></div><div class="">I have a Kamailio and a SIP Phone.</div><div class=""><br class=""></div><div class="">The SIP phone sends a REGISTER to kamailio, then in my routing block, I check if I have an Authorization header.</div><div class=""><br class=""></div><div class="">Since I don't have an Authorization (first message), I use "www_challenge()".</div><div class="">This replies to the SIP phone, and then the SIP phone sends a new REGISTER with the correct Authorization header.</div><div class=""><br class=""></div><div class="">So far so good.</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">The problem is that when the transaction resumes, the tmx module is unhappy and throws this error :</div><div class=""><br class=""></div><div class=""><div 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);" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">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></div></div><div class=""><br class=""></div><div class="">And a 500 error is sent back to the sip phone.</div><div class="">The AUTH_REPLY route is still called and I can use the $http* values.</div><div class=""><br class=""></div><div class="">Do you see something that I am doing wrong or missing in my logic?</div><div class="">Is pausing/resuming to use the async http client is allowed if I'm handling a REGISTER transaction?</div><div class=""><br class=""></div><div class="">Here's a simplified version of my routing block (not far from reality):</div><div class=""><br class=""></div><div class="">##### SNIP </div><div class=""><br class=""></div><div class=""><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class="">request_route{</pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class="">route(AUTH);</pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class=""><br class=""></pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class="">route[AUTH]{</pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class=""><pre style="font-family:Menlo,monospace" class="">    if (is_method(<span style="color:rgb(3,47,98)" class="">"REGISTER"</span>){</pre><pre style="font-family:Menlo,monospace" class="">        if(no_auth_header){</pre><pre style="font-family:Menlo,monospace" class="">            www_challenge(<span style="color:rgb(3,47,98)" class="">"$td"</span>,<span style="color:rgb(3,47,98)" class="">"1"</span>)<span style="color:rgb(106,115,125)" class="">;</span></pre><pre style="font-family:Menlo,monospace" class=""><span style="color:rgb(106,115,125)" class="">            exit;</span></pre><pre style="font-family:Menlo,monospace" class="">        }</pre><pre style="font-family:Menlo,monospace" class="">        else{</pre><pre style="font-family:Menlo,monospace" class="">            t_newtran();</pre><pre style="font-family:Menlo,monospace" class="">            http_async_query(<span style="color:rgb(3,47,98)" class="">"<a href="http://xxx.xxx.xxx.xxx:9000/auth?foo=bar" rel="noreferrer" target="_blank" class="">http://xxx.xxx.xxx.xxx:9000/auth?foo=bar</a>"</span>, <span style="color:rgb(3,47,98)" class="">"AUTH_REPLY"</span>)<span style="color:rgb(106,115,125)" class="">;</span></pre><pre style="font-family:Menlo,monospace" class="">        }</pre><pre style="font-family:Menlo,monospace" class="">    }</pre></pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class="">}</pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class=""><br class=""></pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class="">route[AUTH_REPLY]{</pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class="">    xlog(<span style="color:rgb(3,47,98)" class="">"L_INFO"</span>, <span style="color:rgb(3,47,98)" class="">"route[HTTP_REPLY]: status $http_rs\n"</span>)<span style="color:rgb(106,115,125)" class="">;</span><br class=""></pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class="">}</pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class=""><br class=""></pre><pre style="color:rgb(36,41,46);font-family:Menlo,monospace" class="">}</pre></div><div class="">##### END SNIP</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Best regards!</div>





</div>
__________________________________________________________<br class="">
Kamailio - Users Mailing List - Non Commercial Discussions<br class="">
  * <a href="mailto:sr-users@lists.kamailio.org" rel="noreferrer" target="_blank" class="">sr-users@lists.kamailio.org</a><br class="">
Important: keep the mailing list in the recipients, do not reply only to the sender!<br class="">
Edit mailing list options or unsubscribe:<br class="">
  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer noreferrer" target="_blank" class="">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br class="">
</blockquote></div>
__________________________________________________________<br class="">
Kamailio - Users Mailing List - Non Commercial Discussions<br class="">
  * <a href="mailto:sr-users@lists.kamailio.org" target="_blank" class="">sr-users@lists.kamailio.org</a><br class="">
Important: keep the mailing list in the recipients, do not reply only to the sender!<br class="">
Edit mailing list options or unsubscribe:<br class="">
  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank" class="">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br class="">
</blockquote></div></div>
__________________________________________________________<br class="">Kamailio - Users Mailing List - Non Commercial Discussions<br class="">  * <a href="mailto:sr-users@lists.kamailio.org" class="">sr-users@lists.kamailio.org</a><br class="">Important: keep the mailing list in the recipients, do not reply only to the sender!<br class="">Edit mailing list options or unsubscribe:<br class="">  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" class="">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br class=""></div></blockquote></div><br class=""></body></html>