io.Copy does not work without the sleep + golang sftp-proxy

    time.Sleep(50 * time.Millisecond)

gives enough time for data arrive on psChannel, so when copy is triggered, there is reference to read.

usually pipes are synchronous, although you can achieve async operations it may end up with such hack ways to that tho. an elegant form to achieve what is in the code is using go pipes

as the code says it will exchange data between two channels, a <-> b. if nothing arrives on the first, the whole program cannot work properly. the time.Sleep ensures that readiness. not only, the underlying ssh implementation in use requires a handshake otherwise the server hangs, this might give a fraction of delay.

this implementation btw relies on the example from the ssh NewServerConn doc

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top