Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just got my faye and rails apps hosted on heroku communicating within the past hour or so... here are my observations:</p> <ol> <li><p>Make sure your FAYE_TOKEN is set on all of your servers if you're using an env variable.</p></li> <li><p>Disable websockets, which you've already done... <code>client.disable(...)</code> didn't work for me, I used <code>Faye.Transport.WebSocket.isUsable = function(_,c) { c(false) }</code> instead.</p></li> <li><p>This may or may not apply to you, but was the hardest thing to track down for me... in my dev environment, the port my application is running on will be tacked onto the end of the specified hostname for my faye server... but this appeared to cause a failure to communicate in production. I worked around that by creating a broadcast_server_uri method in application_controller.rb that handles inclusion of a port when necessary, and then use that anywhere I spin up a new channel.</p></li> </ol> <p>....</p> <pre><code>class ApplicationController &lt; ActionController::Base def broadcast_server if request.port.to_i != 80 "http://my-faye-server.herokuapp.com:80/faye" else "http://my-faye-server.herokuapp.com/faye" end end helper_method :broadcast_server def broadcast_message(channel, data) message = { :ext =&gt; {:auth_token =&gt; FAYE_TOKEN}, :channel =&gt; channel, :data =&gt; data} uri = URI.parse(broadcast_server) Net::HTTP.post_form(uri, :message =&gt; message.to_json) end end </code></pre> <p>And in my app javascript, including</p> <pre><code>&lt;script&gt; var broadcast_server = "&lt;%= broadcast_server %&gt;" var faye; $(function() { faye = new Faye.Client(broadcast_server); faye.setHeader('Access-Control-Allow-Origin', '*'); faye.connect(); Faye.Transport.WebSocket.isUsable = function(_,c) { c(false) } // spin off your subscriptions here }); &lt;/script&gt; </code></pre> <p>FWIW, I wouldn't stress about setting Access-Control-Allow-Origin as it doesn't seem to be making a difference either way - I see <code>XMLHttpRequest cannot load http://...</code> regardless, but this should still works well enough to get you unblocked. (although I'd love to learn of a cleaner solution...)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload