Bug #103517 Reconnect to server doesn't reestablish SSH connection
Submitted: 28 Apr 2021 11:35 Modified: 30 Apr 2021 13:37
Reporter: Fredric Johansson Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:8.0.24 OS:Windows
Assigned to: CPU Architecture:Any

[28 Apr 2021 11:35] Fredric Johansson
Description:
When using "Standard TCP/IP over SSH" if the SSH tunnel goes down, for instance due to the computer being suspended overnight, trying to reconnect to the server causes WB to display a cannot connect to mysql dialog. This is likely due to WB mishandling the reconnection for SSH, possibly not giving the mysql connection the right tunnel port.

For now the only way to reconnect if this happens is to close the connection tab and open a new one.

Part of the log:
13:25:52 [INF][    Preferences]: Logger set to level 'debug3' in preferences menu
13:25:53 [DB1][        WQE.net]: Updating display colors
13:25:53 [DB2][            grt]: wb.form.showOptions finished in 7.64s
13:25:57 [INF][     SSH tunnel]: Existing SSH tunnel not found, opening new one
13:25:57 [DB1][ mforms managed]: Looking up password for service: ssh_keyfile@C:\Users\Fredric\Documents\private_ssh_dev2.openssh, account: fredric
13:25:57 [DB1][ mforms managed]: Loading password cache
13:25:57 [DB1][ mforms managed]: Get special folder
13:25:57 [DB2][ mforms managed]: Decrypting password data
13:25:57 [DB2][ mforms managed]: Filling password cache
13:25:57 [DB1][ mforms managed]: Unloading password cache
13:25:57 [DB1][ mforms backend]: Looking up password for 'fredric'@'ssh_keyfile@C:\Users\Fredric\Documents\private_ssh_dev2.openssh' has succeeded
13:25:57 [INF][     SSH tunnel]: Opening SSH tunnel to example.com:22
13:25:57 [DB2][      SSHCommon]: SSH Connection config info:
13:25:57 [DB2][      SSHCommon]: SSH bufferSize: 10240
13:25:57 [DB2][      SSHCommon]: SSH connectTimeout: 10
13:25:57 [DB2][      SSHCommon]: SSH readWriteTimeout: 5
13:25:57 [DB2][      SSHCommon]: SSH commandTimeout: 1
13:25:57 [DB2][      SSHCommon]: SSH commandRetryCount: 3
13:25:57 [DB2][      SSHCommon]: SSH optionsDir: 
13:25:57 [DB2][      SSHCommon]: SSH known hosts file: 
13:25:57 [DB2][      SSHCommon]: SSH local host: 127.0.0.1
13:25:57 [DB2][      SSHCommon]: SSH local port: 0
13:25:57 [DB2][      SSHCommon]: SSH remote host: 127.0.0.1
13:25:57 [DB2][      SSHCommon]: SSH remote port: 3306
13:25:57 [DB2][      SSHCommon]: SSH remote ssh host: example.com
13:25:57 [DB2][      SSHCommon]: SSH remote ssh port: 22
13:25:57 [DB2][      SSHCommon]: SSH strict host key check: yes
13:25:57 [INF][      SSHCommon]: libssh: ssh_connect ssh_connect: libssh 0.9.5 (c) 2003-2019 Aris Adamantiadis, Andreas Schneider and libssh contributors. Distributed under the LGPL, please refer to COPYING file for information about your rights, using threading threads_stdthread
13:25:57 [INF][      SSHCommon]: libssh: ssh_socket_connect ssh_socket_connect: Nonblocking connection socket: 5872
13:25:57 [INF][      SSHCommon]: libssh: ssh_connect ssh_connect: Socket connecting, now waiting for the callbacks to work
13:25:57 [DB3][      SSHCommon]: libssh: socket_callback_connected socket_callback_connected: Socket connection callback: 1 (0)
13:25:57 [INF][      SSHCommon]: libssh: ssh_client_connection_callback ssh_client_connection_callback: SSH server banner: SSH-2.0-OpenSSH_7.4
13:25:57 [INF][      SSHCommon]: libssh: ssh_analyze_banner ssh_analyze_banner: Analyzing banner: SSH-2.0-OpenSSH_7.4
13:25:57 [INF][      SSHCommon]: libssh: ssh_analyze_banner ssh_analyze_banner: We are talking to an OpenSSH client version: 7.4 (70400)
13:25:57 [DB3][      SSHCommon]: libssh: ssh_key_cmp ssh_key_cmp: key types don't match!
13:25:57 [DB3][      SSHCommon]: libssh: ssh_known_hosts_read_entries ssh_known_hosts_read_entries: Failed to open the known_hosts file '/etc/ssh/ssh_known_hosts': No such file or directory
13:25:57 [INF][      SSHCommon]: libssh: ssh_kex_select_methods ssh_kex_select_methods: Negotiated curve25519-sha256@libssh.org,ssh-ed25519,aes256-gcm@openssh.com,aes256-gcm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-256-etm@openssh.com,none,none,,
13:25:57 [INF][      SSHCommon]: libssh: ssh_init_rekey_state ssh_init_rekey_state: Set rekey after 4294967296 blocks
13:25:57 [INF][      SSHCommon]: libssh: ssh_init_rekey_state ssh_init_rekey_state: Set rekey after 4294967296 blocks
13:25:57 [INF][      SSHCommon]: libssh: ssh_packet_client_curve25519_reply ssh_packet_client_curve25519_reply: SSH_MSG_NEWKEYS sent
13:25:57 [INF][      SSHCommon]: libssh: ssh_packet_newkeys ssh_packet_newkeys: Received SSH_MSG_NEWKEYS
13:25:57 [INF][      SSHCommon]: libssh: ssh_packet_newkeys ssh_packet_newkeys: Signature verified and valid
13:25:57 [DB3][      SSHCommon]: libssh: ssh_key_cmp ssh_key_cmp: key types don't match!
13:25:57 [DB3][      SSHCommon]: libssh: ssh_packet_userauth_failure ssh_packet_userauth_failure: Access denied for 'none'. Authentication that can continue: publickey
13:25:57 [INF][      SSHCommon]: libssh: ssh_packet_userauth_failure ssh_packet_userauth_failure: Access denied for 'none'. Authentication that can continue: publickey
13:25:57 [INF][     SSHSession]: Banner: 
13:25:57 [INF][      SSHCommon]: libssh: ssh_pki_import_privkey_base64 ssh_pki_import_privkey_base64: Trying to decode privkey passphrase=true
13:25:57 [DB3][SSHTunnelManager]: About to create ssh tunnel.
13:25:57 [DB2][SSHTunnelManager]: Tunnel port created on socket: 49747
13:25:57 [DB3][SSHTunnelHandler]: Start tunnel handler thread.
13:25:57 [DB2][SSHTunnelManager]: Wakeup socket got connection, reloading socketList.
13:25:57 [INF][     SSH tunnel]: SSH tunnel opened on port: 49747
13:25:57 [DB2][     SSH tunnel]: Increment port usage count: 49747
13:25:57 [DB3][       GRT task]: Sending task "execute sql queries" to dispatcher (wait)...
13:25:57 [DB3][  GRTDispatcher]: Running task "execute sql queries"
13:25:57 [DB2][     SSH tunnel]: Decrement port usage count: 49351
13:25:57 [DB3][SSHTunnelHandler]: Tunnel handler thread stopped.
13:25:57 [DB2][SSHTunnelManager]: Shutdown port: 49351
13:26:57 [ERR][SQL Editor Form]: SqlEditorForm: exception in do_connect method: Exception: Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060
13:26:57 [WRN][SQL Editor Form]: Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060
13:26:57 [ERR][SQL Editor Form]: Connection failed but remote admin does not seem to be available, rethrowing exception...
13:26:57 [ERR][  GRTDispatcher]: exception in grt execute_task, continuing: Exception: Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060
13:26:57 [DB3][  GRTDispatcher]: Task "execute sql queries" finished
13:26:57 [ERR][  GRTDispatcher]: worker: task 'execute sql queries' has failed with error:.Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060
13:26:57 [ERR][SQL Editor Form]: SQL editor could not be connected: Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060
13:26:57 [ERR][SQL Editor Form]: Your connection attempt failed for user 'fredric' to the MySQL server at 127.0.0.1:3306:
  Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060

Please:
1 Check that MySQL is running on address 127.0.0.1
2 Check that MySQL is reachable on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the user fredric has rights to connect to 127.0.0.1 from your address (MySQL rights define what clients can connect to the server and from which machines) 
4 Make sure you are both providing a password if needed and using the correct password for 127.0.0.1 connecting from the host address you're connecting from
13:26:57 [DB1][ mforms managed]: Showing an error to the user
13:26:57 [DB1][ mforms managed]: Hiding the wait message
13:26:57 [DB2][ mforms managed]: Wait message was not visible, nothing to do
13:26:57 [DB1][ mforms managed]: About to show a custom message box
13:26:57 [DB1][ mforms managed]: Creating and showing custom message box
13:26:57 [DB1][ mforms managed]: Running custom message box
13:27:00 [DB1][ mforms managed]: Custom message box closed

How to repeat:
1. Establish a server connection over SSH
2. Break the ssh connection for instance by suspending the computer until the connection times out.
3. Attempt to run a query or manually run Query->Reconnect to server
[30 Apr 2021 13:37] MySQL Verification Team
Hello Fredric Johansson,

Thank you for the bug report.
Imho this is duplicate of Bug #80749, please see Bug #80749.

Regards,
Ashwini Patil