Open sintanial opened 4 years ago
can you elaborate?
Currently this code https://github.com/xtaci/smux/blob/master/session.go#L383 send keepalive frame (cmdNOP) every 10 seconds. During intensive data transfer (cmdPSH), keepalive frames(cmdNOP) are not needed. Because the fact of reading data (cmdPSH) already means that the connection is live.
So, I suggest start sending keepalive frames (cmdNOP) after the last successful reading of data.
The simplest solution is replace https://github.com/xtaci/smux/blob/master/session.go#L384 time.Ticker to time.Timer, and after successful reading cdmPSH reset time.Timer (https://golang.org/pkg/time/#Timer.Reset) ;)
for receiving only connection, it's necessary to send cmdNOP perodically. only 8 bytes in 10 seconds.
Maybe you are right and this is overkill :)
I think, If data is read from a connection, then there is no point in sending a keepalive frame. It is necessary to send the keepalive frame after some timeout from the last read operation. Because success read means that connection is alive, and keepalive frame in this case unnecessary.