Ruby on Rails — Faye Framework — private_pub-open source projects faye/faye
I’m using private_pub to implement a one-to-one chat-like application.
Here is my story: as a user, I would like to receive a message when my partner leaves the chat – closes the window, etc.
Looking through the Faye Monitoring docs here is my attempt at binding on unsubscribe
:
# Run with: rackup private_pub.ru -s thin -E production
require "bundler/setup"
require "yaml"
require "faye"
require "private_pub"
require "active_support/core_ext"
Faye::WebSocket.load_adapter('thin')
PrivatePub.load_config(File.expand_path("../config/private_pub.yml", __FILE__), ENV["RAILS_ENV"] || "development")
wts_pubsub = PrivatePub.faye_app
wts_pubsub.bind(:subscribe) do |client_id, channel|
puts "[#{Time.now}] Client #{client_id} joined #{channel}"
end
wts_pubsub.bind(:unsubscribe) do |client_id, channel|
puts "[#{Time.now}] Client #{client_id} disconnected from #{channel}"
PrivatePub.publish_to channel, { marius_says: 'quitter' }
end
run wts_pubsub
but I keep getting timeouts: [ERROR] [Faye::RackAdapter] Timeout::Error
Prying into PrivatePub#publish_to
, data holds what I expect both when I’m publishing from the Rails or the private_pub app, but the private_pub app keeps hanging.
How can I get publishing from private_pub to work?