fix: auto-reconnect to server after conect failure instead of exiting
This commit is contained in:
parent
f4f60efd47
commit
84d753fa25
1 changed files with 18 additions and 4 deletions
|
@ -109,16 +109,30 @@ where
|
||||||
// Correctly configure tunnel cfg
|
// Correctly configure tunnel cfg
|
||||||
let (ws_rx, ws_tx, response) = match client_cfg.remote_addr.scheme() {
|
let (ws_rx, ws_tx, response) = match client_cfg.remote_addr.scheme() {
|
||||||
TransportScheme::Ws | TransportScheme::Wss => {
|
TransportScheme::Ws | TransportScheme::Wss => {
|
||||||
tunnel::transport::websocket::connect(request_id, &client_cfg, &remote_addr)
|
match tunnel::transport::websocket::connect(request_id, &client_cfg, &remote_addr)
|
||||||
.instrument(span.clone())
|
.instrument(span.clone())
|
||||||
.await
|
.await
|
||||||
.map(|(r, w, response)| (TunnelReader::Websocket(r), TunnelWriter::Websocket(w), response))?
|
{
|
||||||
|
Ok((r, w, response)) => (TunnelReader::Websocket(r), TunnelWriter::Websocket(w), response),
|
||||||
|
Err(err) => {
|
||||||
|
error!("Retrying in 1sec, cannot connect to remote server: {:?}", err);
|
||||||
|
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TransportScheme::Http | TransportScheme::Https => {
|
TransportScheme::Http | TransportScheme::Https => {
|
||||||
tunnel::transport::http2::connect(request_id, &client_cfg, &remote_addr)
|
match tunnel::transport::http2::connect(request_id, &client_cfg, &remote_addr)
|
||||||
.instrument(span.clone())
|
.instrument(span.clone())
|
||||||
.await
|
.await
|
||||||
.map(|(r, w, response)| (TunnelReader::Http2(r), TunnelWriter::Http2(w), response))?
|
{
|
||||||
|
Ok((r, w, response)) => (TunnelReader::Http2(r), TunnelWriter::Http2(w), response),
|
||||||
|
Err(err) => {
|
||||||
|
error!("Retrying in 1sec, cannot connect to remote server: {:?}", err);
|
||||||
|
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue