25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(connection): keep SSH tunnels alive
t8y26b8b2a1009d5
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 842a06b6cb..05d89f6157 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -1572,7 +1572,7 @@ export default {showColumnCommentsInHeaderDescription: "Display table column comments directly below grid column names.",compactColumnHeaderActions: "Compact column header tools",compactColumnHeaderActionsDescription:- "Move sort, formatter, and local filter tools into a more menu so column names get priority.",+ "Move formatter and local filter tools into a more menu so column names get priority.",sidebarActivation: "Sidebar activation",sidebarActivationSingle: "Single click",sidebarActivationSingleDescription: "Open actionable sidebar items with one click.",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 597601a472..c888fbeec8 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -1464,7 +1464,7 @@ export default {"Muestra los comentarios de columnas directamente debajo del nombre de la columna.",compactColumnHeaderActions: "Compactar herramientas del encabezado",compactColumnHeaderActionsDescription:- "Mueve ordenar, formatear y filtrar a un menú de más acciones para priorizar el nombre de columna.",+ "Mueve formatear y filtrar a un menú de más acciones para priorizar el nombre de columna.",sidebarActivation: "Activación de la barra lateral",sidebarActivationSingle: "Un clic",sidebarActivationSingleDescription: "Abrir elementos accionables de la barra lateral con un clic.",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex 548c1fc26d..35df4625bf 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -1542,7 +1542,7 @@ export default {showColumnCommentsInHeader: "在字段名下方显示注释",showColumnCommentsInHeaderDescription: "把表字段注释直接显示在结果表头字段名下方。",compactColumnHeaderActions: "收起字段表头工具",- compactColumnHeaderActionsDescription: "将排序、格式化、本地筛选收进更多菜单,优先显示字段名称。",+ compactColumnHeaderActionsDescription: "将格式化、本地筛选收进更多菜单,优先显示字段名称。",sidebarActivation: "侧边栏打开方式",sidebarActivationSingle: "单击打开",sidebarActivationSingleDescription: "单击即可打开侧边栏中的可操作项目。",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 7521354a29..1885e13d4b 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -1541,7 +1541,7 @@ export default {showColumnCommentsInHeader: "在欄位名稱下方顯示註解",showColumnCommentsInHeaderDescription: "直接在資料表格欄位名稱下方顯示資料表欄位註解。",compactColumnHeaderActions: "收起欄位表頭工具",- compactColumnHeaderActionsDescription: "將排序、格式設定和本機篩選工具移到更多選單,讓欄位名稱優先顯示。",+ compactColumnHeaderActionsDescription: "將格式設定和本機篩選工具移到更多選單,讓欄位名稱優先顯示。",sidebarActivation: "側邊欄開啟方式",sidebarActivationSingle: "單擊開啟",sidebarActivationSingleDescription: "單擊即可開啟側邊欄中的可操作項目。",diff --git a/crates/dbx-core/src/db/ssh_tunnel.rs b/crates/dbx-core/src/db/ssh_tunnel.rsindex 1309bd3872..30746f0e04 100644--- a/crates/dbx-core/src/db/ssh_tunnel.rs+++ b/crates/dbx-core/src/db/ssh_tunnel.rs@@ -8,7 +8,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};use tokio::net::TcpListener;use tokio::sync::Mutex;use tokio::task::JoinHandle;-use tokio::time::Duration;+use tokio::time::{Duration, MissedTickBehavior};use crate::models::connection::SshTunnelConfig;@@ -20,6 +20,10 @@ const INITIAL_RECONNECT_DELAY: Duration = Duration::from_secs(5);const MAX_RECONNECT_DELAY: Duration = Duration::from_secs(60);/// Maximum number of consecutive reconnect attempts before giving up.const MAX_RECONNECT_ATTEMPTS: u32 = 10;+/// How often an idle local listener verifies that the SSH session still answers.+const IDLE_SESSION_CHECK_INTERVAL: Duration = Duration::from_secs(30);+/// Maximum time to wait for an explicit SSH ping response.+const IDLE_SESSION_PING_TIMEOUT: Duration = Duration::from_secs(10);struct SshClient;@@ -93,8 +97,32 @@ async fn connect_and_authenticate(/// Accept connections on the local listener and forward them through the SSH session./// Returns when the SSH session dies (listener error or session.is_closed()).async fn forward_loop(session: &Handle<SshClient>, listener: &TcpListener, remote_host: &str, remote_port: u16) {+ let mut idle_check = tokio::time::interval(IDLE_SESSION_CHECK_INTERVAL);+ idle_check.set_missed_tick_behavior(MissedTickBehavior::Delay);+loop {- let (mut stream, peer_addr) = match listener.accept().await {+ let accepted = tokio::select! {+ result = listener.accept() => result,+ _ = idle_check.tick() => {+ if session.is_closed() {+ log::warn!("SSH session closed while tunnel was idle");+ break;+ }+ match tokio::time::timeout(IDLE_SESSION_PING_TIMEOUT, session.send_ping()).await {+ Ok(Ok(())) => continue,+ Ok(Err(e)) => {+ log::warn!("SSH idle ping failed: {e}");+ break;+ }+ Err(_) => {+ log::warn!("SSH idle ping timed out");+ break;+ }+ }+ }+ };++ let (mut stream, peer_addr) = match accepted {Ok(v) => v,Err(e) => {log::error!("SSH tunnel listener error: {e}");@@ -120,11 +148,7 @@ async fn forward_loop(session: &Handle<SshClient>, listener: &TcpListener, remotOk(c) => c,Err(e) => {log::error!("SSH direct-tcpip failed: {e}");- if session.is_closed() {- log::warn!("SSH session closed after channel open failure");- break;- }- continue;+ break;}};diff --git a/crates/dbx-core/src/query.rs b/crates/dbx-core/src/query.rsindex 2a7ca4201f..eb864f3d69 100644--- a/crates/dbx-core/src/query.rs+++ b/crates/dbx-core/src/query.rs@@ -359,6 +359,7 @@ pub fn is_connection_error(err: &str) -> bool {|| lower.contains("not connected")|| lower.contains("end-of-file")|| lower.contains("idle")+ || lower.contains("communicating with the server")|| is_os_connection_error(&lower)}@@ -1321,6 +1322,7 @@ mod tests {assert!(is_connection_error("Connection timed out"));assert!(is_connection_error("socket closed"));assert!(is_connection_error("unexpected eof"));+ assert!(is_connection_error("Error occurred while creating a new object: error communicating with the server"));}#[test]