async-ssh2
async-ssh2 copied to clipboard
Blocking on stream.read_to_string()
Looks like there is no way to read stream.
channel
.stream(0)
.read_to_string(&mut channel_buffer)
.map_err(|e| Error::msg(format!("Error reading result of work: {}", e)))?;
"Error reading result of work: would block"
Chaning it to
let mut command_stdout = reader(channel.stream(0));
command_stdout
.read_to_string(&mut channel_buffer)
.await
.map_err(|e| Error::msg(format!("Error reading result of work: {}", e)))?;
also doesn't help :(
https://github.com/0xdeafbeef/async-ssh2 This stupid hack works, but better solution exists
I also hit this read_to_string() issue. My solution is to loop on the basic read method of AsyncRead trait with a fixed buffer. Don't know which point break the AsyncReadExt read_to_string derived implementation.