In this post I am going to show how to setup private_pub server on heroku. Private Pub gem is a very nice solution for pushing real time data and it’s open-source . For using the private_pub gem we have to create two application on heroku. First one for our rails app and second one for private_pub server.
Folder structure for private_pub server application is like the below one
fayeserver
config ———–> private_pub.yml
application.rb
boot.rb
script ————> rails
Gemfile
Gemfile.lock
Procfile
private_pub.ru
Note: bold represent folder and other represent file.
“private_pub.yml” and “private_pub.ru” are created by private_pub gem using rails g private_pub:install
Gemfile has following gems
Hi there.. I wanted to thank you for this guide. I haven’t found anyone else trying to explain this process online, so I appreciate it. However, I am having trouble getting it to work. I have created a blank directory and set up a Gemfile with the contents you provide. Bundler works fine, but then when I type “rails g private_pub:install”, Rails just outputs its help text. Is there something I need to do with the directory to have it enable the proper use of the ‘rails’ command? I have never tried to use the ‘rails’ command outside of a rails app before, so I’m a little lost. Any help would be appreciated. Thanks!
Hi Rob,
I have change the folder structure. Now you can checkout the code at https://github.com/Hareramrai/fayeserver .
Thanks,
Hare Ram
That solved my issue. Thank you!
Really helpful.. Thanks buddy
much appreciation, I haven’t found much else where 🙂
Hi,
Thanks so much for your tutorial. It has been really helpful.
I’ve successfully set up the fayeserver on another Heroku app, but when I try to access the fayserver (eg. faye.herokuapp.com) from my rails app (app.herokuapp.com), I get a cross origin access not allowed error. I’m guessing that because the 2 domains were different, so I got the error.
Has this happened to you? Do you know how I can resolve this?
Thanks
Hi Henry,
I have already written a post on how to use private_pub gem on heroku at
https://webprogramming29.wordpress.com/2013/02/15/how-to-use-private_pub-gem-on-heroku-in-ruby-on-rails/ .
I have not faced this issue. Also after faye.herokuapp.com setup try to open in browser if you got “Sure you’re not looking for /faye ?” then it is setup correctly.
Thanks
Ram
Hi,
Thanks for your quick reply. I did indeed follow your tutorial and set it up.
It’s working well on development, but for some reason, I get that error on heroku.
I go to my faye.herokuapp.com and I do indeed see the “Sure you’re not looking for /faye ?”
I can even load the js correctly from faye.herokuapp.com/faye.js
Any thoughts? I’ve been looking all over and could not find a solution.
Thanks,
Henry
Hi Henry,
I have used it to create a application http://batkaro.herokuapp.com/ and its working .
Can share you code ?
Also you can try this https://github.com/Hareramrai/fayeserver/tree/3659492400dac110c4e60cc04f04cd42fbf1397a.
Thanks
Ram
Thanks again. I actually cloned your fayeserver repo and just changed the secret key.
My rails app is a pretty default setup (sorry, it was hosted on a private repo :() I made sure all the configs matched your files as well…
Thanks for your help,
Henry
Oh, so silly of me. I forgot to add and commit a file that I changed for the token.
Not it works 100%.
I’m really sorry and thanks for all your help. The cross origin was really misleading.
Thanks!
Henry
Thanks for your help.
Although the fayeserer works, I sometimes still get “is not allowed by Access-Control-Allow-Origin.” on Chrome. Not sure why that is the case, but it works. Hopefully it won’t affect functionality…
Hello,
My chat application working my on local system.Buy when i deployed it on heroku it creating problem.I have done all set-up on heroku. I tried it with both url : http://ramfayeserver.herokuapp.com/faye and my own application http://fayeserver.herokuapp.com/faye.but couldn’t get success.I noticed that both url faye.js content changed.Is there is an issue.
I have also changed faye version with ‘0.8.8’.
When I try to send message with console I am getting blank array please see details:
curl http://fayeserver.herokuapp.com/faye -d ‘message={“channel”:”/messages/new”, “data”:”hello”, “ext”:”{‘private_pub_token’:’batkaro’}”}’
result : [ ]
I am using same secret_token like example.
Pingback: CheckCheetah: A Rails Web App for Ordering and Paying at a Bar « Rob Williams
Thanks for the help!
Awesome post. Thank you so much!