Hello,

I'm trying to test a Henning's tutorial for Teams SBC described here: https://skalatan.de/en/blog/kamailio-sbc-teams.

A minor change at the MS Teams setup is just about the login. Now it requires MFA.
The license I used is : Microsoft 365 developer subscriptions (E5).
The domanin dv-sbc.openabrik.com is added + 1 user

PS> Connect-MicrosoftTeams (MFA)
PS> New-CsOnlinePSTNGateway -Fqdn dev-sbc.openfabrik.com -SipSignalingPort 5061 -MaxConcurrentSessions 10 -ForwardCallHistory $true -Enabled $true

Everything seems to be OK at MS Teams side.

I'm using the Kamailio coming with Kazoo. Version 5.2.5
[root@dev-sbc kamailio]# kamailio -version
version: kamailio 5.2.5 (x86_64/linux) 
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown 
compiled on 01:14:59 Nov 19 2019 with gcc 7.3.1



When Kamailio is probing MS Teams, the log shows the following errors (for the 3 GW):

hG4bKc188.6a606040000000000000000000000000.0#015#012To: <sip:sip2.pstnhub.microsoft.com;transport=tls>#015#012From: <sip:dev-sbc.openfabrik.com>;tag=d9a52ca041d9e6253dd2a7d5399056e3-2f56#015#012CSeq: 10 OPTIONS#015#012Call-ID: 4ed99b8a73a96dcd-10234@155.138.140.233#015#012Max-Forwards: 70#015#012Content-Length: 0
May  9 01:26:17 dev-sbc kamailio[10234]: ERROR: <core> [core/tcp_main.c:618]: _wbufq_add(): (517 bytes): write queue full or timeout  (0, total 1100374016, last write 41683154 s ago)
May  9 01:26:17 dev-sbc kamailio[10234]: ERROR: <core> [core/tcp_main.c:2673]: tcpconn_1st_send(): 52.114.76.76:5061: EAGAIN and write queue full or failed for 0x7fce434db860
May  9 01:26:17 dev-sbc kamailio[10234]: ERROR: tm [../../core/forward.h:293]: msg_send_buffer(): tcp_send failed
May  9 01:26:17 dev-sbc kamailio[10234]: ERROR: tm [uac.c:648]: send_prepared_request_impl(): Attempt to send to precreated request failed
May  9 01:26:17 dev-sbc kamailio[10234]: INFO: <script>: Sent out tm request to Teams: OPTIONS sip:sip.pstnhub.microsoft.com;transport=tls SIP/2.0#015#012Via: SIP/2.0/TLS 155.138.140.233:5061;branc

config:

tls.cfg

[server:default]
method = TLSv1.2+
verify_certificate = yes
require_certificate = yes
private_key = /etc/letsencrypt/live/openfabrik.com/privkey.pem
certificate = /etc/letsencrypt/live/openfabrik.com/fullchain.pem
ca_list = /etc/letsencrypt/live/openfabrik.com/bc2025.pem
server_name = dev-sbc.openfabrik.com

[client:default]
method = TLSv1.2+
verify_certificate = yes
require_certificate = yes
private_key = /etc/letsencrypt/live/openfabrik.com/privkey.pem
certificate = /etc/letsencrypt/live/openfabrik.com/fullchain.pem
ca_list = /etc/letsencrypt/live/openfabrik.com/bc2025.pem

====

event_route[tm:local-request]
{
    setflag(FLAG_LOCAL_REQUEST);

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

    xlog("L_DEBUG", "$ci|local|start $pr request $rm $ou\n");
    xlog("L_DEBUG", "$ci|local|source $si:$sp -> $dd:$dp\n");
    xlog("L_DEBUG", "$ci|local|from $fu\n");
    xlog("L_DEBUG", "$ci|local|to $tu\n");

    #!ifdef SIP_TRACE_ROLE
    route(SIP_TRACE);
    #!endif

    #!ifdef PRESENCE_ROLE
    route(PRESENCE_LOCAL_REQUEST);
    #!endif

}

====
# setid(integer) destination(sip uri) flags (integer, optional), priority(int,opt), attrs (str,optional)
kamctl dispatcher add 2 'sip:sip.pstnhub.microsoft.com;transport=tls' 0 3 'socket=tls:155.138.140.233:5061;ping_from=sip:dev-sbc.openfabrik.com'
kamctl dispatcher add 3 'sip:sip2.pstnhub.microsoft.com;transport=tls' 0 2 'socket=tls:155.138.140.233:5061;ping_from=sip:dev-sbc.openfabrik.com'
kamctl dispatcher add 4 'sip:sip3.pstnhub.microsoft.com;transport=tls' 0 1 'socket=tls:155.138.140.233:5061;ping_from=sip:dev-sbc.openfabrik.com'

[root@dev-sbc kamailio]# kamctl dispatcher show
dispatcher gateways
sqlite_query: /usr/bin/sqlite3  /etc/kazoo/kamailio/db/kazoo.db select * FROM dispatcher ORDER BY setid; 
1|1|sip:155.138.140.233:11000|9|0|zone=local;profile=sipinterface_1;duid=243;node=freeswitch@dev-sbc.openfabrik.com|added by nodes role
2|2|sip:sip.pstnhub.microsoft.com;transport=tls|0|3|socket=tls:155.138.140.233:5061;ping_from=sip:dev-sbc.openfabrik.com|
3|3|sip:sip2.pstnhub.microsoft.com;transport=tls|0|2|socket=tls:155.138.140.233:5061;ping_from=sip:dev-sbc.openfabrik.com|
4|4|sip:sip3.pstnhub.microsoft.com;transport=tls|0|1|socket=tls:155.138.140.233:5061;ping_from=sip:dev-sbc.openfabrik.com|



Is it a bug on the Kamailio 5.2.5 release or Do I miss something?

Thanks,

Victor