Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sure you're not looking for /faye?

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).

like image 715
jules testard Avatar asked Feb 18 '23 05:02

jules testard


1 Answers

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.

like image 147
jules testard Avatar answered Feb 24 '23 03:02

jules testard