Trying to setup Kamailio with MS Teams Direct Routing.
I am familiar with the integration steps required by Microsoft (using contact header as
FQDN, certified CA for certificate) aswell as the famous guide;
https://skalatan.de/en/blog/kamailio-sbc-teams +
https://learn.microsoft.com/en-us/microsoftteams/direct-routing-protocols-s…
Sending any SIP requests (Invite, ACK, BYE) toward MS is working fine (with provisional
response received in Kamailio) - so there is obviously a working connection between
Kamailio <-> MS Direct Routing environment.
HOWEVER, once Kamailio is forwarding SIP responses to MS (provisional responses/200 OK
received from UAS), then Kamailio is closing the TCP connection.
Please see attached logs below.
Any idea why Kamailio is closing the connection when trying to send provisional responses
to MS?
- Using t_realy on original invite from MS
- tcp_reuse_port=yes, tcp_rd_buf_size = 16384, tcp_connection_lifetime=3605, children=8,
socket_workers=4
- No override rules in firewall
- OS; debian:11.7
- Notice that TLS connection is made on port :26627 - however, MS sends port :5061 in VIA
header (on first Invite). This seems to me to be a conflict in ports.
https://www.kamailio.org/wiki/cookbooks/5.4.x/core#reply_route
"There is no network route that can be enforced for a SIP reply - it is sent based on
Via header, according to SIP RFC3261"
-----
Handshake complete for 52.114.76.76:26627
19(43) DEBUG: tls [tls_domain.c:818]: sr_ssl_ctx_info_callback(): SSL handshake done
19(43) DEBUG: tls [tls_server.c:473]: tls_accept(): TLS accept successful
19(43) DEBUG: tls [tls_server.c:476]: tls_accept(): tls_accept: new connection from
52.114.76.76:26627 using TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256
19(43) DEBUG: tls [tls_server.c:480]: tls_accept(): tls_accept: local socket:
10.129.0.91:5061
19(43) DEBUG: tls [tls_server.c:420]: tls_dump_cert_info(): tls_accept: client certificate
subject:/C=US/ST=WA/L=Redmond/O=Microsoft
Corporation/CN=sip.pstnhub.microsoft.com
19(43) DEBUG: tls [tls_server.c:424]: tls_dump_cert_info(): tls_accept: client certificate
issuer:/C=US/O=Microsoft Corporation/CN=Microsoft Azure RSA TLS Issuing CA 04
-----
Kamailio trying to forward SIP response "183" to MS (response received from
UAS).
Kamailio finds active connection by ID 13 / 0x7f4ecad0be08
20(44) DEBUG: {2 1 INVITE e926eb82d1a25bdc9ba03048cdbc5c77} <core>
[core/tcp_main.c:1722]: _tcpconn_find(): found connection by id: 13
20(44) DEBUG: {2 1 INVITE e926eb82d1a25bdc9ba03048cdbc5c77} <core>
[core/tcp_main.c:2627]: tcpconn_send_put(): tcp connection found (0x7f4ecad0be08),
acquiring fd
20(44) DEBUG: {2 1 INVITE e926eb82d1a25bdc9ba03048cdbc5c77} <core>
[core/tcp_main.c:2637]: tcpconn_send_put(): c=0x7f4ecad0be08, n=16
23(47) DEBUG: <core> [core/tcp_main.c:3982]: handle_ser_child(): read response=
7f4ecad0be08, 2, fd -1 from 20 (44)
20(44) DEBUG: {2 1 INVITE e926eb82d1a25bdc9ba03048cdbc5c77} <core>
[core/tcp_main.c:2665]: tcpconn_send_put(): after receive_fd: c= 0x7f4ecad0be08 n=8 fd=12
20(44) DEBUG: {2 1 INVITE e926eb82d1a25bdc9ba03048cdbc5c77} <core>
[core/tcp_main.c:2842]: tcpconn_do_send(): sending...
20(44) DEBUG: {2 1 INVITE e926eb82d1a25bdc9ba03048cdbc5c77} <core>
[core/tcp_main.c:2878]: tcpconn_do_send(): after real write: c= 0x7f4ecad0be08 n=1191
fd=12
-----
Kamailio immediately closes the connection due to EOF.
19(43) DEBUG: <core> [core/tcp_read.c:280]: tcp_read_data(): EOF on connection
0x7f4ecad0be08 (state: 0, flags: 4018) - FD 10, bytes 0, rd-flags 10000
([52.114.76.76]:26627 -> [52.114.76.76]:5061)19(43) DEBUG: <core>
[core/tcp_read.c:1544]: tcp_read_req(): EOF
19(43) DEBUG: <core> [core/io_wait.h:597]: io_watch_del(): DBG: io_watch_del
(0x555b3cf20260, 10, -1, 0x10) fd_no=2 called
19(43) DEBUG: <core> [core/tcp_read.c:1927]: handle_io(): removing from list
0x7f4ecad0be08 id 13 fd 10, state 2, flags 4018, main fd 57, refcnt 2
([52.114.76.76]:26627 -> [52.114.76.76]:5061)
19(43) DEBUG: <core> [core/tcp_read.c:1702]: release_tcpconn(): releasing con
0x7f4ecad0be08, state -1, fd=10, id=13 ([52.114.76.76]:26627 -> [52.114.76.76]:5061)