Skip to content
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

Blocked behavior when server closes connection while downloading #115

Open
rngtng opened this issue Sep 10, 2020 · 2 comments
Open

Blocked behavior when server closes connection while downloading #115

rngtng opened this issue Sep 10, 2020 · 2 comments

Comments

@rngtng
Copy link

rngtng commented Sep 10, 2020

We've a problem with blocked operation when trying to downloading a non-existent file and therefor the serves closes connection. When I try same operation on shell, No 'file not found' msg is shown, instead connection closed right away.

Ruby code I execute.

file_name = "doesnotexists.file"
Net::SFTP.start(@host, @username, @options) do |sftp|
     data = sftp.download!(file_name)
end

Logs:

I, [2020-09-10T18:41:57.010051 #344]  INFO -- net.sftp.session[c1c]: sending open packet (0)
D, [2020-09-10T18:41:57.011263 #344] DEBUG -- socket[ba4]: queueing packet nr 9 type 94 len 44
D, [2020-09-10T18:41:57.012189 #344] DEBUG -- socket[ba4]: sent 112 bytes
D, [2020-09-10T18:41:57.070221 #344] DEBUG -- socket[ba4]: read 304 bytes
D, [2020-09-10T18:41:57.070756 #344] DEBUG -- socket[ba4]: received packet nr 9 type 96 len 28
I, [2020-09-10T18:41:57.071407 #344]  INFO -- net.ssh.connection.session[c08]: channel_eof: 0
D, [2020-09-10T18:41:57.073445 #344] DEBUG -- socket[ba4]: received packet nr 10 type 98 len 44
I, [2020-09-10T18:41:57.074479 #344]  INFO -- net.ssh.connection.session[c08]: channel_request: 0 exit-status false
D, [2020-09-10T18:41:57.075367 #344] DEBUG -- socket[ba4]: received packet nr 11 type 97 len 28
I, [2020-09-10T18:41:57.075652 #344]  INFO -- net.ssh.connection.session[c08]: channel_close: 0
D, [2020-09-10T18:41:57.076142 #344] DEBUG -- net.sftp.session[c1c]: sftp channel closed
D, [2020-09-10T18:41:57.077775 #344] DEBUG -- socket[ba4]: queueing packet nr 10 type 97 len 28
I, [2020-09-10T18:41:57.078294 #344]  INFO -- net.ssh.connection.session[c08]: host delete channel 0 which closed locally and remotely
D, [2020-09-10T18:41:57.079023 #344] DEBUG -- socket[ba4]: sent 96 bytes

Do we use/config the gem wrong? What's best way to solve this? We had idea first get directory listing, although for a large directory this takes a while. Other idea is to span an additional thread which kill the command after a while.

Any suggestions?

@rngtng rngtng changed the title Infinte when downloading empty or non-existent file Blocked behavior when downloading empty or non-existent file Sep 10, 2020
@rngtng
Copy link
Author

rngtng commented Sep 10, 2020

Update: problem seems that server closes the connection, I see that @sftp.session.channels is empty, but the download event loop still active as on_close isn't called

@rngtng rngtng changed the title Blocked behavior when downloading empty or non-existent file Blocked behavior when server closes connection while downloading Sep 11, 2020
@rngtng
Copy link
Author

rngtng commented Sep 11, 2020

Update: the current workaround we found it to spawn a watch-thread which kills are timeout, see https://stackoverflow.com/questions/9894407/ruby-netsftp-transfer-interrupt-handling

rngtng referenced this issue in net-ssh/net-ssh Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant