3

I have a rails app that uses private_pub. Somehow I can't get my app to connect to private_pub.

Is there a way to bind private_pub to 0.0.0.0?

Run rails server

vagrant@vagrant:/vagrant$ rails s -b 0.0.0.0
=> Booting Thin
=> Rails 4.2.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop

Start private_pub

vagrant@vagrant:/vagrant$ rackup private_pub.ru -s thin -E  production 
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on localhost:9292, CTRL+C to stop

Chrome console log

http://localhost:9292/faye/faye.js net::ERR_EMPTY_RESPONSE
steamboy
  • 1,162
  • 5
  • 20
  • 37

1 Answers1

2

Yes, there is a way, it's documented feature. From docs:

server: The URL to use for the Faye server such as http://localhost:9292/faye.

so you can configure your config/private_pub.yml for the environment you need like this:

development:
  server: "http://0.0.0.0:9292/faye"
  secret_token: "secret"

Then start a server with:

thin -C config/private_pub.yml -p 9292 start
Using rack adapter
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:9292, CTRL+C to stop

I actually don't know why it doesn't catch the port number(I opened the issue in github), so I specified it explicitly.

Second option is to set a host for rackup command(since in this way it doesn't properly handle the address):

rackup private_pub.ru -s thin -E production -o 0.0.0.0
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:9292, CTRL+C to sto

You can also specify explicitly both the address and the port for thin(as well as for rackup) and omit config file at all(probably not a good idea since there are secret_token and signature_expiration options in config file which should be set):

thin -a 0.0.0.0 -p 9292 start
Using rack adapter
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:9292, CTRL+C to stop
Rustam Gasanov
  • 15,290
  • 8
  • 59
  • 72
  • Just run through this again. The details provided above by @rustam works pretty well. But I did encounter a faye connection refused error on the browser console. To fix this 1. set a private network ip on your Vagrant conf 2. on private_pub.rb, use the private network ip on the server config – steamboy Feb 03 '16 at 01:19