如果由于网络差而断开连接,无法检测服务器端的客户端激活状态 - 动作电缆
我们面临着可采取行动的问题。问题是,客户端由于互联网问题而断开连接,但该状态未传达到服务器(断开事件未调用)
由于客户端不活动,以下方法失败,
ActionCable.server.broadcast "project_123_channel", {
"request" => "show_title"
}
Ruby 版本:2.5.3p105 Rails 版本:5.2.3 肌动蛋白电缆版本:5.2.3
断开回调:
App.live_data = App.cable.subscriptions.create({ channel: "ProjectDataChannel", project_id: project_id }, {
collection: function() {
},
connected: function() {
console.log("Live data connected");
},
disconnected: function() {
console.log("disconnected");
return this.perform('unfollow');
}
但是此断开回调不起作用。
有没有办法从服务器端检测客户端的活动状态?或者如果客户端由于互联网原因断开连接,则有任何回调来跟踪断开连接状态
We facing issues with actioncable. The issue is , Client is getting disconnected due to internet issue but that status not communicated to the server(disconnect event not calling)
The below method is failing due to inactive client,
ActionCable.server.broadcast "project_123_channel", {
"request" => "show_title"
}
Ruby version:2.5.3p105
Rails version:5.2.3
actin cable version: 5.2.3
disconnect callback:
App.live_data = App.cable.subscriptions.create({ channel: "ProjectDataChannel", project_id: project_id }, {
collection: function() {
},
connected: function() {
console.log("Live data connected");
},
disconnected: function() {
console.log("disconnected");
return this.perform('unfollow');
}
But this disconnect callback not working.
Is there any way to detect the client active status from server side? or there any callback to track the disconnect status if the client is disconnect due to internet kind of things
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个已知的问题。
这是Vlad Dyachenko的博客文章,描述了问题和解决方案...
https://wowinter13.medium.com/actioncable andling-client-connection-ernection-errors-erors-oner-server-side-93e74178d03
这是帖子中的代码解决方案...
@dbugger的建议很好
This is a known issue.
Here is a blog post from Vlad Dyachenko that describes the problem and a solution...
https://wowinter13.medium.com/actioncable-handling-client-connection-errors-on-server-side-93ea74178d03
This is the code solution from the post...
It's worked fine as suggestion given by @dbugger