You have to use record_route_preset when the message is sent from Kamailio to Teams

if (from_uri =~ ".*microsoft.com") { 
   record_route();
} else {
   record_route_preset("SBC-DNS-DOMAIN:5061;transport=tls", "SBC-IP-ADDR:5060");
}

On Thu, 3 Sep 2020 at 13:13, sip user <sipuser404@gmail.com> wrote:
Thanks Pepelux..

Yes, I follow that post to configure it. But I don´t know where could be the problem and change Record-Route, because, in the post say, only I have to change it when I call from kamailio to Teams, so outgoing calls, right? With record-route-preset... I'm wrong?

Thanks

El jue., 3 sept. 2020 a las 13:07, Pepelux (<pepeluxx@gmail.com>) escribió:
It looks good but in the capture file I saw FQNDIP in RR and not FQNDDNS

This post by Henning may help you: https://skalatan.de/en/blog/kamailio-sbc-teams

And also you can read that:

This is a response from my Kamailio to Teams. Maybe it can be useful for you:

tag: snd
pid: 1394
process: 1
time: 1599126436.582012
date: Thu Sep  3 11:47:16 2020
proto: tls ipv4
srcip: SBC-IP-ADDR
srcport: 5061
dstip: 52.114.75.24
dstport: 5061
~~~~~~~~~~~~~~~~~~~~
SIP/2.0 200 OK
Via: SIP/2.0/TLS 52.114.75.24:5061;branch=z9hG4bK8ac0b4eb
Record-Route: <sip:SBC-DNS-DOMAIN:5060;r2=on;lr>
Record-Route: <sip:SBC-DNS-DOMAIN:5061;transport=tls;r2=on;lr>
Record-Route: <sip:sip-du-a-eu.pstnhub.microsoft.com:5061;transport=tls;lr>
From: Pepelux <sip:+34XXXXXXXXX@sip.pstnhub.microsoft.com:5061;user=phone>;tag=3a6ca98c0a9a46c98ad781c82f389c4d
To: <sip:+34YYYYYYYYY@SBC-DNS-DOMAIN:5061;user=phone>;tag=as524dd8d6
Call-ID: 99ac64b5ad3455be9fd8c838cbdd4c6c
CSeq: 1 INVITE
Server: Asterisk PBX 16.2.1~dfsg-1+deb10u1
Allow:sINVITE, ACK, CANCEL, OPTIONS, BYE, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Contact: <sip:+34YYYYYYYYY@SBC-IP-ADDR:5080>
Content-Type: application/sdp
Content-Length: 532

v=0
o=root 11212956 11212956 IN IP4 SBC-IP-ADDR
s=Asterisk PBX 16.2.1~dfsg-1+deb10u1
c=IN IP4 SBC-IP-ADDR
t=0 0
m=audio 30444 RTP/SAVP 8
a=maxptime:150
a=mid:1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:30445
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:13aivX1dzg2Pbon6bNcvyzNenxMbtvCEh65mnL0t
a=ptime:20
a=ice-ufrag:oysP7oty
a=ice-pwd:Vsv8LeF21onN8NFIKhOvpF53zL
a=candidate:MLkUNexgYqowLxtY 1 UDP 2130706431 SBC-IP-ADDR 30444 typ host
a=candidate:MLkUNexgYqowLxtY 2 UDP 2130706430 SBC-IP-ADDR 30445 typ host
~~~~~~~~~~~~~~~~~~~~
tag: rcv
pid: 1412
process: 19
time: 1599126436.612972
date: Thu Sep  3 11:47:16 2020
proto: tls ipv4
srcip: 52.114.75.24
srcport: 6209
dstip: SBC-IP-ADDR
dstport: 5061
~~~~~~~~~~~~~~~~~~~~
ACK sip:+34YYYYYYYYY@SBC-IP-ADDR:5080 SIP/2.0
FROM: Pepelux <sip:+34XXXXXXXXX@sip.pstnhub.microsoft.com:5061;user=phone>;tag=3a6ca98c0a9a46c98ad781c82f389c4d
TO: <sip:+34YYYYYYYYY@SBC-DNS-DOMAIN:5061>;user=phone;tag=as524dd8d6
CSEQ: 1 ACK
CALL-ID: 99ac64b5ad3455be9fd8c838cbdd4c6c
MAX-FORWARDS: 70
VIA: SIP/2.0/TLS 52.114.75.24:5061;branch=z9hG4bK693bb042
ROUTE: <sip:SBC-DNS-DOMAIN:5061;transport=tls;r2=on;lr>,<sip:SBC-DNS-DOMAIN:5060;r2=on;lr>
CONTACT: <sip:api-du-c-euwe.pstnhub.microsoft.com:443;x-i=21167d9c-8cf9-4253-b059-2d987fadae5a;x-c=99ac64b5ad3455be9fd8c838cbdd4c6c/d/8/90df5d0ec92048de868e268fa57ac0f1>
CONTENT-LENGTH: 0
USER-AGENT: Microsoft.PSTNHub.SIPProxy v.2020.9.1.3 i.EUWE.7
ALLOW: INVITE,ACK,OPTIONS,CANCEL,BYE,NOTIFY


Regards

On Thu, 3 Sep 2020 at 12:34, sip user <sipuser404@gmail.com> wrote:
Hi Pepelux,

I have this one:

remove_hf("Route");
        if (is_method("INVITE|SUBSCRIBE")) {
                if($src_ip != "IP ASTERISK"){
                        record_route();
                        xlog("L_INFO", "***********ROUTE PSTN***********");
                        $rU="1005";
                } else {
                        xlog("L_INFO","LLamada desde $si con puerto $sp");
                        record_route_preset("FQNDDNS:5061;transport=tls", "FQNDIP:5060");
                        add_rr_param(";r2=on");
                        route(DISPATCH);
                        route(RELAY);
                }
        }

When the call is from Teams (src_ip != "IP ASTERISK"), incoming calls, I send the call to 1005 extension. Is here where I have to make the change? Or where?

Thanks

El jue., 3 sept. 2020 a las 12:14, Pepelux (<pepeluxx@gmail.com>) escribió:
Hi

Kamailio doesn't receive any ACK from Teams. I think the problem is the '200 Ok' that you send to Teams is not what he expected. Maybe this is wrong:
Record-Route: <sip:FQNDIP;r2=on;lr>
Record-Route: <sip:FQNDIP:5061;transport=tls;r2=on;lr>

Try to put the registered domain (FQNDDNS) and not de IP address

Regards



On Thu, 3 Sep 2020 at 10:56, sip user <sipuser404@gmail.com> wrote:
Sorry.. Yes, I need to load sipdump.so module..

I attach the result..

Thanks

El mar., 1 sept. 2020 a las 14:03, Pepelux (<pepeluxx@gmail.com>) escribió:
Hi

Have you loaded the module? 

loadmodule "sipdump.so"

On Tue, 1 Sep 2020 at 13:56, sip user <sipuser404@gmail.com> wrote:
Hi pepelux.. When I set:

modparam("sipdump", "enable", 1)

Error, Kamailio not start, error bad config..

Thanks

El mar., 1 sept. 2020 a las 13:45, Pepelux (<pepeluxx@gmail.com>) escribió:
Sorry, I've sent last mail without finishing :)

https://kamailio.org/docs/modules/5.5.x/modules/sipdump.html

You only have to load the module and set:
modparam("sipdump", "enable", 1)

Also you can enable or disable using RPC commands:
kamcmd sipdump.enable
kamcmd sipdump.enable 1
kamcmd sipdump.enable 0

Regards

On Tue, 1 Sep 2020 at 13:37, Pepelux <pepeluxx@gmail.com> wrote:
Hi


You only have to load the module and set:

modparam("sipdump", "enable", 1)

kamcmd sipdump.enable 1
kamcmd sipdump.enable 0
modparam("sipdump", "enable", 1)

On Tue, 1 Sep 2020 at 13:23, sip user <sipuser404@gmail.com> wrote:
Hi Daniel..

And how load sipdump?
I'm using kamailio 5.2.1-1 and I think sipdump module is not available, right?

Thanks

El mar., 1 sept. 2020 a las 12:27, Daniel-Constantin Mierla (<miconda@gmail.com>) escribió:

Hello,

it seems that the ACK comes in, but my guess is that the R-URI is not properly set. From the logs it looks like same value as for To header URI, while it should be the address in Contact header of 200ok for INVITE.

Load the sipdump module and that will save all the sip traffic in a text file, making it easier to see what comes/goes on both directions, no matter is over tls or not. If you use kamailio devel version (master branch), then sipdump module can also store traffic in pcap file (tls traffic saved as udp for simplicity, but it is easy to spot from headers or meta data extra header).

You can send the sipdump file here for investigation, so we can see if some headers or r-uri are not correct.

Cheers,
Daniel

On 01.09.20 11:15, sip user wrote:
Hi Daniel, thanks for answered to me...

With debug=3 I see that:

kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:610]: parse_msg(): SIP Request:
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:612]: parse_msg():  method:  <ACK>
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:614]: parse_msg():  uri:     <sip:+34590@FQND:5061;user=phone;transport=tls>
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:616]: parse_msg():  version: <SIP/2.0>
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/parse_addr_spec.c:185]: parse_to_param(): add param: tag=92e2fd8688a9d17b927d9be2f84faa55-8079
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/parse_addr_spec.c:864]: parse_addr_spec(): end of header reached, state=29
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:171]: get_hdr_field(): <TO> [94]; uri=[sip:+34590@FQND:5061;user=phone]
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:174]: get_hdr_field(): to body [<sip:+34590@FQND:5061;user=phone>], to tag [92e2fd8688a9d17b927d9be2f84faa55-8079]
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:152]: get_hdr_field(): cseq <CSEQ>: <1> <ACK>
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/parse_via.c:1303]: parse_via_param(): Found param type 232, <branch> = <z9hG4bKf4784e39>; state=16
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/parse_via.c:2639]: parse_via(): end of header reached, state=5
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:498]: parse_headers(): Via found, flags=2
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:500]: parse_headers(): this is the first via
kamailio[1096]:  9(1109) DEBUG: <core> [core/receive.c:240]: receive_msg(): --- received sip message - request - call-id: [d3649f52dc0057768ec6c18733de8206] - cseq: [1 ACK]
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:185]: get_hdr_field(): content_length=0
kamailio[1096]:  9(1109) DEBUG: <core> [core/parser/msg_parser.c:89]: get_hdr_field(): found end of header
kamailio[1096]:  9(1109) DEBUG: {1 1 ACK d3649f52dc0057768ec6c18733de8206} <core> [core/receive.c:295]: receive_msg(): preparing to run routing scripts...
kamailio[1096]:  9(1109) DEBUG: {1 1 ACK d3649f52dc0057768ec6c18733de8206} sl [sl_funcs.c:397]: sl_filter_ACK(): too late to be a local ACK!

So, I understand that ACK comes from Teams, right? So kamailio routing problem?

Thanks

El mar., 25 ago. 2020 a las 15:32, Daniel-Constantin Mierla (<miconda@gmail.com>) escribió:

Hello,

run with debug=3 in kamailio.cfg and see if the ACK comes to Kamailio, if yes, then some routing issue in kamailio.cfg. If does not come, you will have to check the headers to see if MS Teams expects something else there, typically is about Record-Route domains...

Cheers,
Daniel

On 20.08.20 12:25, sip user wrote:
Hi, I'm connecting Teams with kamailio server. From Kamailio to teams I have no problems, but from teams to Kamailio yes. Drop the call..

With ngrep I see that:

INVITE sip:1005@CLIENT_IP:55766;transport=UDP;rinstance=d47edf336726e940 SIP/2.0.
Record-Route: <sip:FQND_IP;r2=on;lr>.
Record-Route: <sip:FQND_IP:5061;transport=tls;r2=on;lr>.
FROM: "Javier Gonz..lez Mu..oz"<sip:+324@sip.pstnhub.microsoft.com:5061;user=phone>;tag=c17bb1eb7f8649d4a89d8d4a876ac32b.
TO: <sip:+34560@FQND:5061;user=phone>.
CSEQ: 1 INVITE.
CALL-ID: c1364913e582553a9a9c2544c3583b0a.
MAX-FORWARDS: 69.
Via: SIP/2.0/UDP 92.222.217.64;branch=z9hG4bK7bb5.0fbae76a37829205e04279f220a26af2.0;i=a1.
VIA: SIP/2.0/TLS 52.114.76.76:5061;branch=z9hG4bKd216a55.
RECORD-ROUTE: <sip:sip-du-a-eu.pstnhub.microsoft.com:5061;transport=tls;lr>.
CONTACT: <sip:api-du-a-euno.pstnhub.microsoft.com:443;x-i=b0b53fc5-76ef-4619-9a68-13e0a4eea92d;x-c=c1364913e582553a9a9c2544c3583b0a/d/8/6c25eb3789a14bf188ce6b05b5e27891>.
CONTENT-LENGTH: 1091.
MIN-SE: 300.
SUPPORTED: timer.
USER-AGENT: Microsoft.PSTNHub.SIPProxy v.2020.7.31.1 i.EUNO.0.
CONTENT-TYPE: application/sdp.
ALLOW: INVITE,ACK,OPTIONS,CANCEL,BYE,NOTIFY.
P-ASSERTED-IDENTITY: <tel:+324>,<sip:EMAIL>.
PRIVACY: id.
SESSION-EXPIRES: 3600.
.
v=0.
o=- 165103 0 IN IP4 127.0.0.1.
s=session.
c=IN IP4 52.113.44.8.
b=CT:10000000.
t=0 0.
m=audio 50452 RTP/SAVP 104 9 103 111 18 0 8 97 101 13 118.
c=IN IP4 52.113.44.8.
a=rtcp:50453.
a=ice-ufrag:FZTb.
a=ice-pwd:yD3P7nr+xNq0VYdv7xpB1F+Y.
a=rtcp-mux.
a=candidate:1 1 UDP 2130706431 52.113.44.8 50452 typ srflx raddr 10.0.33.240 rport 50

U CLIENT_IP:55766 -> FQND_IP:5060 #2
SIP/2.0 180 Ringing.
Via: SIP/2.0/UDP FQND_IP;branch=z9hG4bK7bb5.0fbae76a37829205e04279f220a26af2.0;i=a1.
Via: SIP/2.0/TLS 52.114.76.76:5061;branch=z9hG4bKd216a55.
Record-Route: <sip:FQND_IP;lr;r2=on>.
Record-Route: <sip:FQND_IP:5061;transport=tls;r2=on;lr>.
Record-Route: <sip:sip-du-a-eu.pstnhub.microsoft.com:5061;transport=tls;lr>.
Contact: <sip:1005@CLIENT_IP:55766;transport=UDP;rinstance=d47edf336726e940>.
To: <sip:+34560@FQND:5061;user=phone>;tag=de4e6b45.
From: "Javier Gonz..lez Mu..oz"<sip:+324@sip.pstnhub.microsoft.com:5061;user=phone>;tag=c17bb1eb7f8649d4a89d8d4a876ac32b.
Call-ID: c1364913e582553a9a9c2544c3583b0a.
CSeq: 1 INVITE.
User-Agent: 3CXPhone 6.0.26523.0.
Content-Length: 0.

U CLIENT_IP:55766 -> FQND_IP:5060 #3
SIP/2.0 200 OK.
Via: SIP/2.0/UDP FQND_IP;branch=z9hG4bK7bb5.0fbae76a37829205e04279f220a26af2.0;i=a1.
Via: SIP/2.0/TLS 52.114.76.76:5061;branch=z9hG4bKd216a55.
Record-Route: <sip:FQND_IP;lr;r2=on>.
Record-Route: <sip:FQND_IP:5061;transport=tls;r2=on;lr>.
Record-Route: <sip:sip-du-a-eu.pstnhub.microsoft.com:5061;transport=tls;lr>.
Contact: <sip:1005@CLIENT_IP:55766;transport=UDP;rinstance=d47edf336726e940>.
To: <sip:+34560@FQND:5061;user=phone>;tag=de4e6b45.
From: "Javier Gonz..lez Mu..oz"<sip:+324@sip.pstnhub.microsoft.com:5061;user=phone>;tag=c17bb1eb7f8649d4a89d8d4a876ac32b.
Call-ID: c1364913e582553a9a9c2544c3583b0a.
CSeq: 1 INVITE.
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REGISTER, SUBSCRIBE, NOTIFY, REFER, INFO, MESSAGE.
Content-Type: application/sdp.
Supported: replaces.
User-Agent: 3CXPhone 6.0.26523.0.
Content-Length: 1067.
.
v=0.
o=3cxVCE 324945090 117647850 IN IP4 .
s=3cxVCE Audio Call.
t=0 0.
m=audio 0 RTP/SAVP 104 9 103 111 18 0 8 97 101 13 118.
c=IN IP4 52.113.44.8.
a=rtpmap:104 SILK/16000.
a=rtpmap:9 G722/8000.
a=rtpmap:103 SILK/8000.
a=rtpmap:111 SIREN/16000.
a=fmtp:111 bitrate=16000.
a=rtpmap:18 G729/8000.
a=fmtp:18 annexb=no.
a=rtpmap:0 PCMU/8000.
a=rtpmap:8 PCMA/8000.
a=rtpmap:97 RED/8000.
a=rtpmap:101 telephone-event/8000.
a=fmtp:101 0-16.
a=rtpmap:13 CN/8000.
a=rtpmap:118 CN/16000.
a=rtcp:50453.
a=ice-ufrag:FZTb.
a=ice-pwd:yD3P7nr+xNq0VYdv7xpB1F+Y.
a=rtcp-mux.
a=candidate:1 1 UDP 213

I never received ACK..

In my configuration:

Kamailio.cfg:

#!KAMAILIO
#!define WITH_TLS

event_route[tm:local-request] {

        if(is_method("OPTIONS") && $ru =~ "pstnhub.microsoft.com") {
               append_hf("Contact: <sip:FQND:5061;transport=tls>\r\n");
        }
        xlog("L_INFO", "Sent out tm request: $mb\n");
}

request_route{

       remove_hf("Route");
        if (is_method("INVITE|SUBSCRIBE")) {
                xlog("L_INFO","$fU is trying to call to $rU con valores $tu\n");
                $rU="1005";
        }
}

What I'm doing wrong?

I don't understand why not received ACK..

Could anyone help me?

Thanks

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Funding: https://www.paypal.me/dcmierla
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Funding: https://www.paypal.me/dcmierla
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users