diff --git a/conf/testing/sip_profiles/internal.xml b/conf/testing/sip_profiles/internal.xml
index 2a3564ebb4..d7b2ef893d 100644
--- a/conf/testing/sip_profiles/internal.xml
+++ b/conf/testing/sip_profiles/internal.xml
@@ -216,6 +216,14 @@
+
+
+
diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml
index 58350e827b..85692fa631 100644
--- a/conf/vanilla/sip_profiles/internal.xml
+++ b/conf/vanilla/sip_profiles/internal.xml
@@ -216,6 +216,14 @@
+
+
+
diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h
index 9a739088df..9d0d150354 100644
--- a/src/mod/endpoints/mod_sofia/mod_sofia.h
+++ b/src/mod/endpoints/mod_sofia/mod_sofia.h
@@ -761,6 +761,7 @@ struct sofia_profile {
uint32_t timer_t1x64;
uint32_t timer_t2;
uint32_t timer_t4;
+ uint32_t tls_orq_connect_timeout;
char *contact_user;
char *local_network;
uint32_t trans_timeout;
diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c
index f31367a04c..a71678dd10 100644
--- a/src/mod/endpoints/mod_sofia/sofia.c
+++ b/src/mod/endpoints/mod_sofia/sofia.c
@@ -3220,6 +3220,10 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
TPTAG_PONG2PING(1),
NTATAG_TCP_RPORT(0),
NTATAG_TLS_RPORT(0),
+#ifdef NTATAG_TLS_ORQ_CONNECT_TIMEOUT
+ TAG_IF(profile->tls_orq_connect_timeout,
+ NTATAG_TLS_ORQ_CONNECT_TIMEOUT(profile->tls_orq_connect_timeout)), /* Profile based timeout */
+#endif
NUTAG_RETRY_AFTER_ENABLE(0),
NUTAG_AUTO_INVITE_100(0),
TAG_IF(!strchr(profile->sipip, ':'),
@@ -5917,6 +5921,13 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
} else {
profile->timer_t4 = 4000;
}
+ } else if (!strcasecmp(var, "tls-orq-connect-timeout") && !zstr(val)) {
+ int v = atoi(val);
+ if (v > 0) {
+ profile->tls_orq_connect_timeout = v;
+ } else {
+ profile->tls_orq_connect_timeout = 0;
+ }
} else if (!strcasecmp(var, "sip-options-respond-503-on-busy")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_OPTIONS_RESPOND_503_ON_BUSY);
diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c
index 68125879ce..9a6a7acbd9 100644
--- a/src/mod/endpoints/mod_sofia/sofia_glue.c
+++ b/src/mod/endpoints/mod_sofia/sofia_glue.c
@@ -1068,6 +1068,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
const char *stir_shaken_attest = NULL;
char *identity_to_free = NULL;
const char *date = NULL;
+ const char *sip_call_tls_orq_connect_timeout = switch_channel_get_variable(tech_pvt->channel, "sip_call_tls_orq_connect_timeout");
if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD_INACTIVE) ||
@@ -1400,6 +1401,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
NUTAG_URL(url_str),
TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)),
TAG_IF(!zstr(record_route), SIPTAG_HEADER_STR(record_route)),
+#ifdef NUTAG_CALL_TLS_ORQ_CONNECT_TIMEOUT
+ /* Per call tls outgoing request connect timeout */
+ TAG_IF(sip_call_tls_orq_connect_timeout, NUTAG_CALL_TLS_ORQ_CONNECT_TIMEOUT(atoi(sip_call_tls_orq_connect_timeout))),
+#endif
SIPTAG_TO_STR(to_str), SIPTAG_FROM_STR(from_str), SIPTAG_CONTACT_STR(invite_contact), TAG_END()))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,