-
Notifications
You must be signed in to change notification settings - Fork 151
SocketRecvError #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's pretty much the same for me. I do not get Example from pssh.clients.native import ParallelSSHClient
def run_command(host_list, cmd):
client = ParallelSSHClient(host_list)
output = client.run_command(cmd)
# https://parallel-ssh.readthedocs.io/en/latest/output.html
for host in output.values():
print("Command STDOUT:")
for line in host.stdout:
print(line)
print("Command STDERR:")
for line in host.stderr:
print(line)
print(f"Command exit code: {host.exit_code}") If I run Sample output
SSH config on target hosts
This means that keepalive packets are sent from the target hosts to the script-running machine to prevent SSH connections from disconnecting. 3 keepalive packets must not be unanswered for a session to disconnect. Those setting work perfectly well for 1 host executing a long-running command. |
Can you please enable debug logging and post log output for the two cases. Switches typically have non-standard SSH implementations, though if it works on one it should work with the other as long as the SSH server is the same (is it?).
|
Thank you for the prompt reply @pkittenis! Debug log
|
Thank you for the debug output.
|
Target hosts are created dynamically from the same AWS Amazon Machine Image, i.e. they are pretty much identical. Only IP addresses change. They get terminated after each run.
Yes, sure. The output of running `sleep 600` on only one machine.
And finally here is a showcase of successfully running a command on all 5 servers. When they run fast, there are no issues. The output of running `sleep 10; date` on 5 machines
Please let me know if I can provide some other piece of information to make the troubleshooting easier. |
Does running |
I think i have the same problem when using Single SSHClient?: here is my code: import re if 1==1: o=client.run_command('ls')o=client.run_command('command 1') print(status) if 1==1: o=client.run_command('ls | head -n 1')o=client.run_command('command 2') status = '' print(status)
Traceback (most recent call last): |
my problem somehow happens because client.disconnect() is interfering with the the SSHClient() of block 2. If i remove disconnect() from block 1; it works as it should. |
Cannot reproduce. Simple example script with sleep and reading both stdout/stderr:
Output:
Single clients:
Output:
For reporting issues please provide a clear and reproducible example. |
Note that heavy IDE environments that make use of threads, threading happening inside client code, multiprocessing et al will all interfere with
As above, please provide a reproducible example to best get good help with an issue. |
Reproduced on a server running: Run the following code in a python notebook, or a script. I get a SocketRecvError about 80% of the time.
Output:
|
Thanks, can reproduce. Looks like issue with single client disconnections from last version. |
As a workaround, call This works correctly:
|
…on disconnected sessions. Resolves #200
Issue was if channel EOF was not sent prior to disconnection, state can be left in libssh2. On subsequent open sessions, libssh2 attempts to EOF the left over channel. If the prior socket data is not available libssh2 can send corrupt packet to server and server terminates connection as seen in libssh2 trace messages.
Latest changes stop this from happening by not closing socket before channel can clean itself up. Sessions are disconnected correctly on both parallel and single client deletion/out of scope. Calling Any other similar issue please report - reproducible example is very useful to get good help.
|
Confirmed also that in 1.11.2 this is resolved. Thanks so much for an extremely quick fix!! |
Sometimes I get a SocketRcvError after the script execution
Traceback (most recent call last):
File "C:/Users/btissi/PycharmProjects/Test/script_4_test.py", line 41, in
for line in host_output.stdout:
File "C:\Users\btissi\PycharmProjects\Test\venv\lib\site-packages\pssh\clients\native\single.py", line 401, in read_output_buffer
for line in output_buffer:
File "pssh/native/_ssh2.pyx", line 45, in _read_output
File "ssh2\channel.pyx", line 116, in ssh2.channel.Channel.read
File "ssh2\channel.pyx", line 144, in ssh2.channel.Channel.read_ex
File "ssh2\utils.pyx", line 179, in ssh2.utils.handle_error_codes
ssh2.exceptions.SocketRecvError
The code is the follow:
When I run the code with only one hosts it works like a charm and doesn't raise any exceptions.
Switches model: WS-C3750X-48PF-S
Is it a common problem?
The text was updated successfully, but these errors were encountered: