我看到了
ActionCable.server.open_connections_statistics
、ActionCable.server.connections.length
、ActionCable.server.connections.map(&:statistics)
、ActionCable.server.connections.select(&:beat).count
等内容,但这只是“每个进程”的(服务器、控制台、服务器工作者等等)。那么如何查找此时订阅ActionCable的所有人呢?这应该在各个环境(开发、暂存、生产)的任何Rails进程中返回相同的值。例如,在开发控制台中,您也可以看到开发服务器上的连接,因为它们理论上使用相同的订阅适配器(redis、async、postgres)。
Rails 5.0.0.beta3,Ruby 2.3.0
gid://myproject/User/250581
。我猜这个字符串的具体形式取决于你在identify_by
中使用的是什么。 - 2called-chaosRedis.new(url: 'redis://:auth_code@ip:port/db_number').pubsub('channels', 'action_cable/*').map { |c| Base64.decode64(c.split('/').last) }
- EvmorovActionCable.server.pubsub.send(:redis_connection)
获取ActionCable
的 Redis 连接(而不是自己创建),使用ActionCable.server.pubsub.send(:channel_with_prefix, "action_cable/*")
获取正确的频道名称。 - Oded Niv