<p>Hi,</p>
<p>I have a provider that requires proxy auth for all outgoing calls so I create the following config:</p>
<pre><code>loadmodule "uac.so"
loadmodule "dialog.so"
modparam("dialog", "dlg_flag", 4)
modparam("dialog", "track_cseq_updates", 1)
modparam("dialog", "send_bye", 1)
modparam("dialog", "timeout_noreset", 1)
modparam("uac","auth_realm_avp","$avp(s:auth_realm_avp)")
modparam("uac","auth_username_avp","$avp(s:auth_username_avp)")
modparam("uac","auth_password_avp","$avp(s:auth_password_avp)")

route {
        ......
        dlg_manage();

        # dispatch destinations to PSTN
        route(PSTN);

        ......
}

failure_route[MANAGE_FAILURE] {
        route(NATMANAGE);

        if (t_is_canceled()) {
                exit;
        }
        if (t_check_status("401|407"))
        {
                $avp(s:auth_realm_avp) = "realm";
                $avp(s:auth_username_avp) = "user";
                $avp(s:auth_password_avp) = "pass";
                if (uac_auth()) {
                        xlog("L_INFO", "[MANAGE_FAILURE] did auth. Relaying to new destination. from=$fu, callee-selected-by=$ou, uri=$ru");
                        t_relay();
                        exit;
                } else {
                        xlog("L_INFO", "[MANAGE_FAILURE] no matching realm found. realm=$ar");
                }
        }
}
</code></pre>
<p>Based on this authentication happens correctly however when canceling the call from the caller side, incorrect CSeq value is sent to the PSTN trunk:</p>
<p>INVITE sip:48221028000@<strong>provider</strong>:6050 SIP/2.0<br>
Record-Route: sip:x.x.216.50;lr=on;ftag=327099285;did=14e.8df<br>
Max-Forwards: 19<br>
Via: SIP/2.0/UDP x.x.216.50;branch=z9hG4bKa108.115652a5d470ecc5427124e7926af3b2.0<br>
Via: SIP/2.0/UDP x.x.219.61:1049;received=x.x.219.61;rport=1049;branch=z9hG4bK1237457362<br>
From: sip:48221028008@x.x.216.50;tag=327099285<br>
To: sip:48221028000@x.x.216.50<br>
Call-ID: 1015351791@x.x.216.50<br>
Allow: ACK, INVITE, BYE, CANCEL, OPTIONS, INFO<br>
CSeq: 74 INVITE<br>
Content-Type: application/sdp<br>
Content-Length: 481</p>
<p>v=0<br>
o=yate 1483794545 1483794545 IN IP4 x.x.219.61<br>
s=SIP Call<br>
c=IN IP4 x.x.219.61<br>
t=0 0<br>
m=audio 21596 RTP/AVP 0 8 11 98 97 102 103 104 105 106 101<br>
a=rtpmap:0 PCMU/8000<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:11 L16/8000<br>
a=rtpmap:98 iLBC/8000<br>
a=fmtp:98 mode=20<br>
a=rtpmap:97 iLBC/8000<br>
a=fmtp:97 mode=30<br>
a=rtpmap:102 SPEEX/8000<br>
a=rtpmap:103 SPEEX/16000<br>
a=rtpmap:104 SPEEX/32000<br>
a=rtpmap:105 iSAC/16000<br>
a=rtpmap:106 iSAC/32000<br>
a=rtpmap:101 telephone-event/8000<br>
a=ptime:30</p>
<p>SIP/2.0 407 Proxy Authentication Required<br>
Via: SIP/2.0/UDP x.x.216.50;branch=z9hG4bKa108.115652a5d470ecc5427124e7926af3b2.0;received=x.x.216.50<br>
Via: SIP/2.0/UDP x.x.219.61:1049;received=x.x.219.61;rport=1049;branch=z9hG4bK1237457362<br>
From: sip:48221028008@x.x.216.50;tag=327099285<br>
To: sip:48221028000@x.x.216.50;tag=as386df8c6<br>
Call-ID: 1015351791@x.x.216.50<br>
CSeq: 74 INVITE<br>
User-Agent: Adescom CTM5000<br>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO<br>
Max-Forwards: 70<br>
Proxy-Authenticate: Digest realm="adescom", nonce="080cd7c6"<br>
Content-Length: 0</p>
<p>ACK sip:48221028000@<strong>provider</strong>:6050 SIP/2.0<br>
Max-Forwards: 19<br>
Via: SIP/2.0/UDP x.x.216.50;branch=z9hG4bKa108.115652a5d470ecc5427124e7926af3b2.0<br>
From: sip:48221028008@x.x.216.50;tag=327099285<br>
To: sip:48221028000@x.x.216.50;tag=as386df8c6<br>
Call-ID: 1015351791@x.x.216.50<br>
CSeq: 74 ACK<br>
Content-Length: 0</p>
<p>INVITE sip:48221028000@<strong>provider</strong>:6050 SIP/2.0<br>
Record-Route: sip:x.x.216.50;lr=on;ftag=327099285;did=14e.8df<br>
Max-Forwards: 19<br>
Via: SIP/2.0/UDP x.x.216.50;branch=z9hG4bKa108.115652a5d470ecc5427124e7926af3b2.1.cs74<br>
Via: SIP/2.0/UDP x.x.219.61:1049;received=x.x.219.61;rport=1049;branch=z9hG4bK1237457362<br>
From: sip:48221028008@x.x.216.50;tag=327099285<br>
To: sip:48221028000@x.x.216.50<br>
Call-ID: 1015351791@x.x.216.50<br>
Allow: ACK, INVITE, BYE, CANCEL, OPTIONS, INFO<br>
CSeq: 75 INVITE<br>
Content-Type: application/sdp<br>
Content-Length: 481<br>
Proxy-Authorization: Digest username="<strong><em>USER</em></strong>", realm="adescom", nonce="080cd7c6", uri="sip:48221028000@<strong>provider</strong>:6050", response="521afedacdfa7033339e4956580bb0ec", algorithm=MD5</p>
<p>v=0<br>
o=yate 1483794545 1483794545 IN IP4 x.x.219.61<br>
s=SIP Call<br>
c=IN IP4 x.x.219.61<br>
t=0 0<br>
m=audio 21596 RTP/AVP 0 8 11 98 97 102 103 104 105 106 101<br>
a=rtpmap:0 PCMU/8000<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:11 L16/8000<br>
a=rtpmap:98 iLBC/8000<br>
a=fmtp:98 mode=20<br>
a=rtpmap:97 iLBC/8000<br>
a=fmtp:97 mode=30<br>
a=rtpmap:102 SPEEX/8000<br>
a=rtpmap:103 SPEEX/16000<br>
a=rtpmap:104 SPEEX/32000<br>
a=rtpmap:105 iSAC/16000<br>
a=rtpmap:106 iSAC/32000<br>
a=rtpmap:101 telephone-event/8000<br>
a=ptime:30</p>
<p>SIP/2.0 100 Trying<br>
Via: SIP/2.0/UDP x.x.216.50;branch=z9hG4bKa108.115652a5d470ecc5427124e7926af3b2.1.cs74;received=x.x.216.50<br>
Via: SIP/2.0/UDP x.x.219.61:1049;received=x.x.219.61;rport=1049;branch=z9hG4bK1237457362<br>
From: sip:48221028008@x.x.216.50;tag=327099285<br>
To: sip:48221028000@x.x.216.50<br>
Call-ID: 1015351791@x.x.216.50<br>
CSeq: 75 INVITE<br>
User-Agent: Adescom CTM5000<br>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO<br>
Max-Forwards: 70<br>
Contact: sip:48221028000@85.14.79.130:6050<br>
Content-Length: 0<br>
X-CTMG-HangupCause: Normal Clearing</p>
<p>SIP/2.0 183 Session Progress<br>
Via: SIP/2.0/UDP x.x.216.50;branch=z9hG4bKa108.115652a5d470ecc5427124e7926af3b2.1.cs74;received=x.x.216.50<br>
Via: SIP/2.0/UDP x.x.219.61:1049;received=x.x.219.61;rport=1049;branch=z9hG4bK1237457362<br>
From: sip:48221028008@x.x.216.50;tag=327099285<br>
To: sip:48221028000@x.x.216.50;tag=as1fa0d5d0<br>
Call-ID: 1015351791@x.x.216.50<br>
CSeq: 75 INVITE<br>
User-Agent: Adescom CTM5000<br>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO<br>
Max-Forwards: 70<br>
Contact: sip:48221028000@85.14.79.130:6050<br>
Content-Type: application/sdp<br>
Content-Length: 226</p>
<p>v=0<br>
o=root 7839 7839 IN IP4 85.14.79.130<br>
s=session<br>
c=IN IP4 85.14.79.130<br>
t=0 0<br>
m=audio 30688 RTP/AVP 8 101<br>
a=rtpmap:8 PCMA/8000<br>
a=ptime:20<br>
a=rtpmap:101 telephone-event/8000<br>
a=fmtp:101 0-16<br>
a=silenceSupp:off - - - -</p>
<p>CANCEL sip:48221028000@<strong>provider</strong>:6050 SIP/2.0<br>
Max-Forwards: 19<br>
Via: SIP/2.0/UDP x.x.216.50;branch=z9hG4bKa108.115652a5d470ecc5427124e7926af3b2.1<br>
From: sip:48221028008@x.x.216.50;tag=327099285<br>
To: sip:48221028000@x.x.216.50<br>
Call-ID: 1015351791@x.x.216.50<br>
CSeq: 74 CANCEL<br>
Content-Length: 0</p>
<p>SIP/2.0 500 Server error<br>
Via: SIP/2.0/UDP x.x.216.50;branch=z9hG4bKa108.115652a5d470ecc5427124e7926af3b2.1;received=x.x.216.50<br>
From: sip:48221028008@x.x.216.50;tag=327099285<br>
To: sip:48221028000@x.x.216.50;tag=as1fa0d5d0<br>
Call-ID: 1015351791@x.x.216.50<br>
CSeq: 74 CANCEL<br>
User-Agent: Adescom CTM5000<br>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO<br>
Max-Forwards: 70<br>
Content-Length: 0<br>
X-CTMG-HangupCause: Normal Clearing</p>
<p>Since I'm new to Kamailio, I figured I must be doing something wrong but don't seem to find any working example anywhere....</p>
<p>-G</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/918">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZYTotvX8J-eDIIV2rYi8-lrNPGZYks5rP5FFgaJpZM4Lda2j">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZfzmZkBU6VkYfVMPZeGJ5wFA2c5Tks5rP5FFgaJpZM4Lda2j.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/918"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"CSeq issues with CANCEL after INVITE (#918)"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/918"}}}</script>