4

I am following this tutorial to the letter :

http://net.tutsplus.com/tutorials/ruby/how-to-use-faye-as-a-real-time-push-server-in-rails/

I have installed thin, faye and written the following in the faye.ru file :

require 'faye'
bayeux = Faye::RackAdapter.new(:mount => '/faye', :timeout => 25)
bayeux.listen(9292)

But when I start the rack up server :

rackup faye.ru -E production -s thin

The server does start correctly :

>> Thin web server (v1.5.0 codename Knife)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:9292, CTRL+C to stop

But when I access any webpage, such as "http://localhost:9292/", I get the following message :

Sure you're not looking for /faye ?

And the neither this tutorial nor Ryan Bates rails cast #260 give an explanation of why this is happening. Does somebody have an idea?

I must say that my project is using ruby version 1.8.7 (and I can't upgrade to 1.9 because some of the gems I use do not support 1.9 yet).

jules testard
  • 193
  • 1
  • 9
  • well you are binding faye to /faye, so the above makes sense. And glancing at the the tutorial it shows all the interaction going to the /faye mount point. The rest of the stuff is handled by your rails app which listens on a different port. – Doon Dec 10 '12 at 14:39

3 Answers3

5

Ok, actually everything works fine, I was just not understanding what Faye was supposed to do.

The Faye server does not replace the Rails server but rather complements it. I was expecting to see the same thing on localhost:3000 and localhost:9292.

In case somebody else is confused like I was, you have to run both servers at the same time:

Rails server :

 rails server [with your options if any]

Faye server to handle JS channels :

 rackup faye.ru -s thin -E production

And the users interact with the rails server only (on port 3000) and leave the Faye server run in the background.

jules testard
  • 193
  • 1
  • 9
2

You're still supposed to use port 3000 (unless you've changed the default port or something). 9292 is just being used for Faye, only.

Try going to "http://localhost:3000"

MrDanA
  • 11,489
  • 2
  • 36
  • 47
1

The output looks good to me.

Try to look for

http://localhost:9292/faye.js

instead of

http://localhost:9292/
Batist
  • 303
  • 2
  • 9