<p></p>
<h3>Description</h3>
<p>Thank you for implementing <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="667225596" data-permission-text="Title is private" data-url="https://github.com/kamailio/kamailio/issues/2413" data-hovercard-type="issue" data-hovercard-url="/kamailio/kamailio/issues/2413/hovercard" href="https://github.com/kamailio/kamailio/issues/2413">#2413</a>, I'm looking forward to use it.</p>
<p>I was trying it on a dev system. It works fine when the same TLS client needs to be selected for ALL connections.</p>
<p>Having issue with it when connection expected to alternate between multiple configured TLS clients.<br>
When configured as bellow and event_route alternates between connections (like in logs bellow) connection is always using  TLSc with one of the server-ids, e.g. "domain-02".</p>
<p>It looks like it's a race between setting server id in event_route and a "thread" that starts TLS client. In my observations only one TLS client is used.</p>
<p>Expecting: each outbound connection use TLSc as it was set by tls_set_connect_server_id().</p>
<pre><code>event_route[tm:local-request] {
        if (is_method("OPTIONS")) {
               $var(contact) = "Contact: <sip:" + $fd + ":5061;transport=tls>\r\n";
               append_hf("$var(contact)");

               if ($fd == "domain-01") {
                  tls_set_connect_server_id("domain-01");
                  xlog("L_INFO", "ID=$ci|tls_set_connect_server_id(domain-01)\n");
               } else if ($fd == "domain-02") {
                  tls_set_connect_server_id("domain-02");
                  xlog("L_INFO", "ID=$ci|tls_set_connect_server_id(domain-02)\n");
               }
        }
}
</code></pre>
<p>Dispatcher configured as:</p>
<pre><code>loadmodule "dispatcher.so"
modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
modparam("dispatcher", "ds_probing_mode", 1)
modparam("dispatcher", "ds_ping_interval", 60)
</code></pre>
<p>With records like:</p>
<pre><code>1 sip:sip1.host.com;transport=tls  0 1 socket=tls:111.222.233.11:5061;ping_from=sip:my-domain-01.com
1 sip:sip2.host.com;transport=tls  0 2 socket=tls:111.222.233.12:5061;ping_from=sip:my-domain-01.com
1 sip:sip3.host.com;transport=tls  0 3 socket=tls:111.222.233.13:5061;ping_from=sip:my-domain-01.com
2 sip:sip1.host.com;transport=tls  0 1 socket=tls:111.222.233.21:5061;ping_from=sip:my-domain-02.com
2 sip:sip2.host.com;transport=tls  0 2 socket=tls:111.222.233.22:5061;ping_from=sip:my-domain-02.com
2 sip:sip3.host.com;transport=tls  0 3 socket=tls:111.222.233.23:5061;ping_from=sip:my-domain-02.com
</code></pre>
<h4>Log Messages</h4>
<pre><code>Jun  3 11:57:44  INFO: <script>: ID=4eadda397f10fcb1-948@1.2.3.4|tls_set_connect_server_id(domain-02) 
Jun  3 11:57:44  INFO: <script>: ID=4eadda397f10fcb2-948@1.2.3.4|tls_set_connect_server_id(domain-01) 
Jun  3 11:57:44  INFO: <script>: ID=4eadda397f10fcb3-948@1.2.3.4|tls_set_connect_server_id(domain-02) 
Jun  3 11:57:44  INFO: <script>: ID=4eadda397f10fcb4-948@1.2.3.4|tls_set_connect_server_id(domain-01) 
Jun  3 11:57:44  INFO: <script>: ID=4eadda397f10fcb5-948@1.2.3.4|tls_set_connect_server_id(domain-02) 
Jun  3 11:57:44  INFO: <script>: ID=4eadda397f10fcb6-948@1.2.3.4|tls_set_connect_server_id(domain-01) 

</code></pre>
<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>version: kamailio 5.5.0 (x86_64/linux) 
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, 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_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
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 with gcc 7.5.0
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>
<pre><code>Linux dev03 4.15.0-143-generic #147-Ubuntu SMP Wed Apr 14 16:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu 18.04.5 LTS
</code></pre>

<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/2760">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZJRA7VBP7E26X4PWL3TQ6X27ANCNFSM46BFDBOA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZMJEGR4DZIFFN53SH3TQ6X27A5CNFSM46BFDBOKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4NSH6RTA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2760",
"url": "https://github.com/kamailio/kamailio/issues/2760",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>