DialSSHTimeout - It is impossible to read timeout
lpzgithub opened this issue · 1 comments
lpzgithub commented
I used the DialSSHTimeout for testing read Timeout. I intentionally send the server not to know the message and produce the reading timeout.But the reality is that read has not Timeout. I found that the data it read was the data returned by KEEP_ALIVE.
The interval of KEEP_ALIVE is half of the reading of Timeout.
go func() {
ticker := time.NewTicker(timeout / 2)
defer ticker.Stop()
for range ticker.C {
_, _, err := t.sshClient.Conn.SendRequest("KEEP_ALIVE", true, nil)
if err != nil {
return
}
}
}()
func (c *deadlineConn) Read(b []byte) (n int, err error) {
c.SetReadDeadline(time.Now().Add(c.timeout))
return c.Conn.Read(b)
}
lpzgithub commented
ok, thanks. close this.