{"id":7599,"date":"2015-09-07T08:24:43","date_gmt":"2015-09-07T08:24:43","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/09\/07\/ruby-on-rails-faye-framework-private_pub-open-source-projects-faye-faye\/"},"modified":"2015-09-07T08:24:43","modified_gmt":"2015-09-07T08:24:43","slug":"ruby-on-rails-faye-framework-private_pub-open-source-projects-faye-faye","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/09\/07\/ruby-on-rails-faye-framework-private_pub-open-source-projects-faye-faye\/","title":{"rendered":"Ruby on Rails &#8212; Faye Framework &#8212; private_pub-open source projects faye\/faye"},"content":{"rendered":"<p>I&#8217;m using private_pub to implement a one-to-one chat-like application.<\/p>\n<p>Here is my story: as a user, I would like to receive a message when my partner leaves the chat \u2013 closes the window, etc.<\/p>\n<p>Looking through the Faye Monitoring docs here is my attempt at binding on <code>unsubscribe<\/code>:<\/p>\n<pre><code># Run with: rackup private_pub.ru -s thin -E production\nrequire \"bundler\/setup\"\nrequire \"yaml\"\nrequire \"faye\"\nrequire \"private_pub\"\nrequire \"active_support\/core_ext\"\n\nFaye::WebSocket.load_adapter('thin')\n\nPrivatePub.load_config(File.expand_path(\"..\/config\/private_pub.yml\", __FILE__),     ENV[\"RAILS_ENV\"] || \"development\")\n\nwts_pubsub = PrivatePub.faye_app\n\nwts_pubsub.bind(:subscribe) do |client_id, channel|\nputs \"[#{Time.now}] Client #{client_id} joined  #{channel}\"\nend\n\nwts_pubsub.bind(:unsubscribe) do |client_id, channel|\n  puts \"[#{Time.now}] Client #{client_id} disconnected from #{channel}\"\n  PrivatePub.publish_to channel, { marius_says: 'quitter' }\nend\n\nrun wts_pubsub\n<\/code><\/pre>\n<p>but I keep getting timeouts: <code>[ERROR] [Faye::RackAdapter] Timeout::Error<\/code><\/p>\n<p>Prying into <code>PrivatePub#publish_to<\/code>, data holds what I expect both when I&#8217;m publishing from the Rails or the private_pub app, but the private_pub app keeps hanging.<\/p>\n<p>How can I get publishing from private_pub to work?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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 \u2013 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7599","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7599"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7599\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}