From 22930f26b16bd8adc4f13c3d2c735f1207b20b0e Mon Sep 17 00:00:00 2001 From: marcbrevoort-cyberhive <69469731+marcbrevoort-cyberhive@users.noreply.github.com> Date: Thu, 7 Mar 2024 11:25:21 +0000 Subject: [PATCH] Update relay_conn.rs If a channel bind (refresh) fails with a stale nonce error, the nonce should be refreshed and the attempt should be retried. --- turn/src/client/relay_conn.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/turn/src/client/relay_conn.rs b/turn/src/client/relay_conn.rs index 33f8d769e..829e11bee 100644 --- a/turn/src/client/relay_conn.rs +++ b/turn/src/client/relay_conn.rs @@ -567,6 +567,17 @@ impl RelayConnInternal { let res = tr_res.msg; + if res.typ.class == CLASS_ERROR_RESPONSE { + let mut code = ErrorCodeAttribute::default(); + let result = code.get_from(&res); + if result.is_err() { + return Err(Error::Other(format!("{}", res.typ))); + } else if code.code == CODE_STALE_NONCE { + self.set_nonce_from_msg(&res); + return Err(Error::ErrTryAgain); + } + } + if res.typ != MessageType::new(METHOD_CHANNEL_BIND, CLASS_SUCCESS_RESPONSE) { return Err(Error::ErrUnexpectedResponse); }