[英]How to keep the session alive within WebSocket in Dart?
HttpSession's lastSeen is updated only if there is a new request. HttpSession的lastSeen仅在有新请求时才更新。 However, in my environment, I have a WebSocket connection and I'd like to keep the session alive as long as the Web connection is alive.
但是,在我的环境中,我有一个WebSocket连接,并且只要Web连接处于活动状态,我都希望保持会话处于活动状态。 But, I can't find a right method to do it.
但是,我找不到正确的方法来做到这一点。
Firing another HTTP request periodically could be a solution, but I'm looking for something that can be done within the WebScoket's handler.
定期触发另一个HTTP请求可能是一种解决方案,但我正在寻找可以在WebScoket的处理程序中完成的操作。
Note: the WebSocket connection won't be closed.
注意:WebSocket连接不会关闭。 Rather, the session can be timed out.
而是,会话可以超时。 It means
request.session
can return a different instance when processing one WebSocket message.这意味着
request.session
在处理一条WebSocket消息时可以返回不同的实例。
As far as I know the WebSockets already have support for ping control frames to keep the connection alive. 据我所知,WebSockets已经支持ping控制帧以保持连接有效。 See The official spec .
请参阅官方规格 。
As far as I can tell I have never seen an WebSocket to be closed early. 据我所知,我从未见过WebSocket早日关闭。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.