TrueBlocks / trueblocks-core

The main repository for the TrueBlocks system
https://trueblocks.io
GNU General Public License v3.0
1.06k stars 202 forks source link

Multiple connections being created #3908

Open tjayrush opened 2 weeks ago

tjayrush commented 2 weeks ago

An interaction with chat about our browse code:

This is a log of my ssh interaction with another computer during hte operation of my local app (that uses the connection). Do you see anything weird?

OpenSSH_9.4p1, LibreSSL 3.3.6
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to 100.19.36.234 [100.19.36.234] port 23456.
debug1: Connection established.
debug1: identity file /Users/jrush/.ssh/id_rsa type -1
debug1: identity file /Users/jrush/.ssh/id_rsa-cert type -1
debug1: identity file /Users/jrush/.ssh/id_ecdsa type -1
debug1: identity file /Users/jrush/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/jrush/.ssh/id_ecdsa_sk type -1
debug1: identity file /Users/jrush/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /Users/jrush/.ssh/id_ed25519 type -1
debug1: identity file /Users/jrush/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/jrush/.ssh/id_ed25519_sk type -1
debug1: identity file /Users/jrush/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /Users/jrush/.ssh/id_xmss type -1
debug1: identity file /Users/jrush/.ssh/id_xmss-cert type -1
debug1: identity file /Users/jrush/.ssh/id_dsa type -1
debug1: identity file /Users/jrush/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.11
debug1: compat_banner: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.11 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 100.19.36.234:23456 as 'jrush'
debug1: load_hostkeys: fopen /Users/jrush/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:XadJS3XVhiOizfW1YRXxFYJiQqsdpGEHv1YHOrg8WVw
debug1: load_hostkeys: fopen /Users/jrush/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '[100.19.36.234]:23456' is known and matches the ED25519 host key.
debug1: Found key in /Users/jrush/.ssh/known_hosts:27
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent contains no identities
debug1: Will attempt key: /Users/jrush/.ssh/id_rsa
debug1: Will attempt key: /Users/jrush/.ssh/id_ecdsa
debug1: Will attempt key: /Users/jrush/.ssh/id_ecdsa_sk
debug1: Will attempt key: /Users/jrush/.ssh/id_ed25519
debug1: Will attempt key: /Users/jrush/.ssh/id_ed25519_sk
debug1: Will attempt key: /Users/jrush/.ssh/id_xmss
debug1: Will attempt key: /Users/jrush/.ssh/id_dsa
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/jrush/.ssh/id_rsa
Authenticated to 100.19.36.234 ([100.19.36.234]:23456) using "publickey".
debug1: Local connections to LOCALHOST:23457 forwarded to remote address localhost:8545
debug1: Local forwarding listening on ::1 port 23457.
debug1: channel 0: new port-listener [port listener] (inactive timeout: 0)
debug1: Local forwarding listening on 127.0.0.1 port 23457.
debug1: channel 1: new port-listener [port listener] (inactive timeout: 0)
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: client_input_hostkeys: searching /Users/jrush/.ssh/known_hosts for [100.19.36.234]:23456 / (none)
debug1: client_input_hostkeys: searching /Users/jrush/.ssh/known_hosts2 for [100.19.36.234]:23456 / (none)
debug1: client_input_hostkeys: hostkeys file /Users/jrush/.ssh/known_hosts2 does not exist
debug1: client_input_hostkeys: host key found matching a different name/address, skipping UserKnownHostsFile update
debug1: pledge: network
debug1: Remote: /home/jrush/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 2: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 3: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: channel 2: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52676 to ::1 port 23457, nchannels 4
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 2: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 4: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 5: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 6: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 7: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 8: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 9: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 10: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 11: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 12: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 13: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 14: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 15: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 16: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 17: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 18: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 19: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 20: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 21: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 22: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 23: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 24: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 25: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 26: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 27: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 28: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 29: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 30: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 31: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 32: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 33: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 34: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 35: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 36: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 37: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 38: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 39: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 40: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 41: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 42: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 43: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 44: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 45: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 46: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 47: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 48: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 49: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 50: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 51: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 52: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 53: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 54: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 55: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 51: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 52: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 53: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 54: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 55: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: Connection to port 23457 forwarding to localhost port 8545 requested.
debug1: channel 56: new direct-tcpip [direct-tcpip] (inactive timeout: 0)
debug1: channel 23: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52700 to ::1 port 23457, nchannels 57
debug1: channel 39: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52715 to ::1 port 23457, nchannels 56
debug1: channel 42: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52718 to ::1 port 23457, nchannels 55
debug1: channel 44: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52721 to ::1 port 23457, nchannels 54
debug1: channel 46: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52723 to ::1 port 23457, nchannels 53
debug1: channel 36: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52713 to ::1 port 23457, nchannels 52
debug1: channel 4: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52679 to ::1 port 23457, nchannels 51
debug1: channel 5: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52682 to ::1 port 23457, nchannels 50
debug1: channel 18: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52695 to ::1 port 23457, nchannels 49
debug1: channel 31: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52708 to ::1 port 23457, nchannels 48
debug1: channel 43: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52720 to ::1 port 23457, nchannels 47
debug1: channel 49: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52726 to ::1 port 23457, nchannels 46
debug1: channel 33: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52710 to ::1 port 23457, nchannels 45
debug1: channel 51: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52728 to ::1 port 23457, nchannels 44
debug1: channel 56: free: direct-tcpip: listening port 23457 for localhost port 8545, connect from ::1 port 52733 to ::1 port 23457, nchannels 43

ChatGPT said:

From your SSH debug log, here are a few observations:

Repeated Port Forwarding Requests: There are numerous requests for port forwarding to localhost:8545, with many new channels being created (debug1: channel X: new direct-tcpip [direct-tcpip]). This pattern could indicate that your local app is making repeated connections to the remote service on port 8545, potentially due to a rapid polling or continuous reconnection attempt.

Channel Overuse and Closure: Later in the log, channels start closing (debug1: channel X: free: direct-tcpip), suggesting the SSH session might be reaching a channel limit, which can cause performance issues or slowdowns in communication. This is likely due to the high frequency of requests on the same port.

Known Host Issues: The log also shows several entries where it couldn’t locate host key files (/Users/jrush/.ssh/known_hosts2 and /etc/ssh/ssh_known_hosts2), although this doesn’t seem critical since it still authenticated successfully.

Recommendations Check Application Behavior: Review your application’s connection code to ensure it’s not repeatedly opening new connections. If polling is necessary, consider using a longer interval or switching to a persistent connection model.

Increase Channel Limit: If you need multiple connections, you may be able to adjust the SSH channel limits on the server by configuring MaxSessions in your SSH server’s configuration (sshd_config).