-
Notifications
You must be signed in to change notification settings - Fork 3k
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
ssh: stdout stalls at under 1MB of data mark #7483
Comments
would it be a problem for you to provide reproduction code in Erlang? |
GPT4: -module(sshwrap).
-export([connect/1, connect/2, connect/3, connect/4, close/1, execute_async/3, execute_sync/3, execute/2]).
-export([execute_2/1, execute_2/3]).
connect(Host) ->
connect(Host, "root", 22, nil).
connect(Host, User) ->
connect(Host, User, 22, nil).
connect(Host, User, Port) ->
connect(Host, User, Port, nil).
connect(Host, User, Port, Pass) ->
Args = [
{user, User},
{silently_accept_hosts, true},
{user_interaction, false},
{connect_timeout, 8000}
],
Args2 = case Pass of
nil -> Args;
_ -> [{password, Pass}|Args]
end,
{ok, Ref} = ssh:connect(Host, Port, Args2, 8000),
Ref.
close(Ref) ->
ssh:close(Ref).
execute_async(Host, User, Cmd) ->
Ref = connect(Host, User),
{ok, ChannelId} = ssh_connection:session_channel(Ref, infinity),
success = ssh_connection:exec(Ref, ChannelId, Cmd, infinity),
Ref.
execute_sync(Host, User, Cmd) ->
Ref = connect(Host, User),
{R,E} = execute(Ref, Cmd),
ssh:close(Ref),
{R,E}.
execute(Ref, Cmd) ->
{ok, ChannelId} = ssh_connection:session_channel(Ref, infinity),
success = ssh_connection:exec(Ref, ChannelId, Cmd, infinity),
execute_2(Ref).
execute_2(Ref) ->
execute_2(Ref, <<>>, nil).
execute_2(Ref, Buf, Errno) ->
receive
{ssh_cm, Ref, {data, _, _, Bin}} -> execute_2(Ref, erlang:iolist_to_binary([Buf, Bin]), Errno);
{ssh_cm, Ref, {exit_status, _, Err}} -> execute_2(Ref, Buf, Err);
{ssh_cm, Ref, {eof, _}} -> execute_2(Ref, Buf, Errno);
{ssh_cm, Ref, {closed, _}} -> {Buf, Errno}
after 900000 ->
timeout
end.
|
To add to this, if a process exits that has opened a ssh connection, the connection is not terminated, thus its not cleaned up properly. Eventually this leads to a flooded kernel keyring |
thanks for update. we consider this important to fix, but had to schedule it due to other work and summer period. |
FYI, work on fixing this is ongoing. |
can you give some suggestion on reproducing this? |
|
unfortunately, behavior reported here was not an bug(or at least should not be interpreted as on by me) and supposed fix in PR-8345 introduced unwanted behavior and manifested with for example long transfers over SFTP hanging as described in GH-8724. Due to above, adjustment previously made in ssh_connection module was reverted in PR-9309. Behavior described in this issue will re-appear with upcoming emergency patches for supported OTP versions. My thinking is that behavior is expected according to ssh application design. such support functionality is available for modules using I would propose updating the docs to explain that and maybe also provide an example as a resolution to this issue. |
Describe the bug
After receiving just under 1MB of data through the channel, stdout stalls and no data is received anymore, channel stays open no close is sent.
Affected versions
OTP 25
The text was updated successfully, but these errors were encountered: