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

Unnecessary keepalive frames #66

Open
sintanial opened this issue Feb 19, 2020 · 4 comments
Open

Unnecessary keepalive frames #66

sintanial opened this issue Feb 19, 2020 · 4 comments

Comments

@sintanial
Copy link
Contributor

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.

@xtaci
Copy link
Owner

xtaci commented Feb 19, 2020

can you elaborate?

@sintanial
Copy link
Contributor Author

sintanial commented Feb 19, 2020

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) ;)

@xtaci
Copy link
Owner

xtaci commented Feb 20, 2020

for receiving only connection, it's necessary to send cmdNOP perodically. only 8 bytes in 10 seconds.

@sintanial
Copy link
Contributor Author

Maybe you are right and this is overkill :)

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

2 participants