From 8d428f44847399d9e858ff0090934db095ba8ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Fri, 5 Mar 2021 10:38:30 -0500 Subject: [PATCH] pjproject: increase timer value for TURN connection timeout On some very slow network, the process to connect to a relay candidates can take a lot of time. Cause this timer includes the time between the ConnectionAttempt and sending the Binding response. With some packet loss it can quickly increase this delay. Example: Classic nego (Successful ICE): 10:36:28.126 .RX 144 bytes STUN message from 51.222.10.40:3478: --- begin STUN message --- STUN ConnectionAttempt indication (...) 10:36:29.378 .TX 84 bytes STUN message to IP:45320: --- begin STUN message --- STUN Binding success response Problematic case on a bad network: // Bad network peer 09:39:10.910 .RX 288 bytes STUN message from 192.252.140.236:3478: --- begin STUN message --- STUN ConnectionAttempt indication // other PEER: 09:38:51.855 192.252.140.236:11846 (nominated): connectivity check FAILED: STUN transaction has timed out (PJNATH_ESTUNTIMEDOUT) => The other peer close the socket // Bad network peer 09:38:52.258 .RX 76 bytes STUN message from IP:36436: --- begin STUN message --- STUN ConnectionBind success response 9:38:53.756 tcprel0x7f7098178460 .socket send(): Not found (PJ_ENOTFOUND) The value of 15 secs is chosen to follow ice_inactive_timeout in the webrtc's sources (CONNECTION_WRITE_TIMEOUT) Change-Id: Idc66f6cb2018fbf03e34059640fa91601535dcb1 GitLab: #1201 --- contrib/src/pjproject/0001-rfc6544.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/src/pjproject/0001-rfc6544.patch b/contrib/src/pjproject/0001-rfc6544.patch index 1201d1aad1..790c980783 100644 --- a/contrib/src/pjproject/0001-rfc6544.patch +++ b/contrib/src/pjproject/0001-rfc6544.patch @@ -961,8 +961,8 @@ index 2a4125bc5..b10a8fb51 100644 + if (set_timer && ice->timer_connect.id == TIMER_NONE) { + /* Reschedule */ + pj_time_val delay = { -+ .sec = 0, -+ .msec = 1500 ++ .sec = 15, ++ .msec = 0 + }; + pj_time_val_normalize(&delay); + pj_timer_heap_schedule_w_grp_lock(ice->stun_cfg.timer_heap, @@ -1102,8 +1102,8 @@ index 2a4125bc5..b10a8fb51 100644 + pj_assert(!"Not expected any timer active"); + } else { + pj_time_val delay = { -+ .sec = 0, -+ .msec = 1500, ++ .sec = 15, ++ .msec = 0, + }; + pj_time_val_normalize(&delay); + pj_timer_heap_schedule_w_grp_lock(ice->stun_cfg.timer_heap, -- GitLab