From 6a5768534ab31f852522a7ef28bb836eaaedf1b5 Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Wed, 21 Aug 2024 12:23:02 +0100 Subject: [PATCH] Retry connecting to broker in bridge test proxy Signed-off-by: James Rhodes --- crates/extensions/tedge_mqtt_bridge/tests/bridge.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/extensions/tedge_mqtt_bridge/tests/bridge.rs b/crates/extensions/tedge_mqtt_bridge/tests/bridge.rs index 340a5fbd62..6bf02e1f23 100644 --- a/crates/extensions/tedge_mqtt_bridge/tests/bridge.rs +++ b/crates/extensions/tedge_mqtt_bridge/tests/bridge.rs @@ -501,7 +501,12 @@ impl Proxy { let mut stop = stop_rx.clone(); stop.mark_unchanged(); if let Ok((mut socket, _)) = listener.accept().await { - let mut conn = tokio::net::TcpStream::connect(&target).await.unwrap(); + let mut conn = loop { + let Ok(conn) = tokio::net::TcpStream::connect(&target).await else { + continue; + }; + break conn; + }; tokio::spawn(async move { let (mut read_socket, mut write_socket) = socket.split(); let (mut read_conn, mut write_conn) = conn.split();