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

如何让websocket 连接保持更长时间? #18

Closed
flymark2010 opened this issue Jul 18, 2018 · 5 comments
Closed

如何让websocket 连接保持更长时间? #18

flymark2010 opened this issue Jul 18, 2018 · 5 comments

Comments

@flymark2010
Copy link

Hi, 在登录到远程服务器后,如果不进行任何操作,web终端很快就会关闭(大约50s)。 请问如何可以使连接保持更长时间?

谢谢!

@huashengdun
Copy link
Owner

服务器有用nginx吗?

@flymark2010
Copy link
Author

用了nginx和不用nginx都一样的。
现在通过设置参数websocket_ping_interval,和websocket_ping_timeout 可以保持长连接了。

@huashengdun
Copy link
Owner

保持长连接有两种方式,一种是TCP keepalive. 还有一种 ping/pong。
我测试下来, chrome和firefox websocket 会不间断发送 TCP keepalive。
所以并不要需要启用tornado的ping机制。

@flymark2010
Copy link
Author

我测试的时候发现tornado不设置websocket_ping_interval的话,就没法保持长连接,不知道是不是和浏览器相关(我用的也是chrome)。 不过现在通过在tornado后端设置,已经达到保持长连接的目的了。
非常感谢。

@huashengdun
Copy link
Owner

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