Setup PrivatePub or Faye on heroku

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


config ———–> private_pub.yml
script ————> rails




Note: bold represent folder and other represent file.

“private_pub.yml” and “” are created by private_pub gem using rails g private_pub:install

Gemfile has following gems

source ‘
    gem ‘rails’,’3.2.12′
    gem ‘private_pub’
    gem ‘thin’
    gem ‘foreman’
After adding the gem ,  bundle it. Then run “rails g private_pub:install”.
Initialize the repository by git init.
After that create a heroku app using “heroku apps:create fayserver”. I am using app name as “fayserver” but it can be changed.
Then change the private_pub.yml file content to
  secret_token: “batkaro”
  signature_expiration: 86400 # one day
After that commit the code and push the code to heroku .
Now finally  we are ready to  use it. 🙂

You can checkout my github repository for fayserver code

16 thoughts on “Setup PrivatePub or Faye on heroku

  1. 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!

  2. 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. from my rails app (, 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 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,

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


  3. 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…

  4. 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 : and my own application 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 -d ‘message={“channel”:”/messages/new”, “data”:”hello”, “ext”:”{‘private_pub_token’:’batkaro’}”}’
    result : [ ]

    I am using same secret_token like example.

  5. Pingback: CheckCheetah: A Rails Web App for Ordering and Paying at a Bar « Rob Williams

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s