diff --git a/libs/hbb_common/src/socket_client.rs b/libs/hbb_common/src/socket_client.rs index d00b5e759..a797acf33 100644 --- a/libs/hbb_common/src/socket_client.rs +++ b/libs/hbb_common/src/socket_client.rs @@ -4,7 +4,7 @@ use crate::{ udp::FramedSocket, ResultType, }; -use anyhow::{bail, Context}; +use anyhow::bail; use std::net::SocketAddr; use tokio::net::ToSocketAddrs; use tokio_socks::{IntoTargetAddr, TargetAddr}; @@ -69,9 +69,7 @@ pub async fn connect_tcp<'t, T: IntoTargetAddr<'t>>( bail!("Invalid target addr"); }; - FramedStream::new(addrs[0], local, ms_timeout) - .await - .with_context(|| "Failed to connect to rendezvous server") + Ok(FramedStream::new(addrs[0], local, ms_timeout).await?) } } diff --git a/src/common.rs b/src/common.rs index 6a96db464..13f013540 100644 --- a/src/common.rs +++ b/src/common.rs @@ -249,7 +249,7 @@ async fn test_nat_type_() -> ResultType { if port == 0 { bail!("Invalid server address: {}", server1); } - let server2 = format!("{}:{}", tmp[0], port); + let server2 = format!("{}:{}", tmp[0], port - 1); let mut msg_out = RendezvousMessage::new(); let serial = Config::get_serial(); msg_out.set_test_nat_request(TestNatRequest {