How I can set to listen defined ip address?

1,765 views
Skip to first unread message

JPascal

unread,
Oct 16, 2011, 12:21:39 PM10/16/11
to Faye users
By default server listen 0.0.0.0 address, how i can change this?

server = Faye::RackAdapter.new(:mount => @options[:mount], :timeout =>
@options[:timeout])
server.listen(@options[:port])

James Coglan

unread,
Oct 16, 2011, 6:55:07 PM10/16/11
to faye-...@googlegroups.com
On 16 October 2011 17:21, JPascal <eshu...@gmail.com> wrote:
By default server listen 0.0.0.0 address, how i can change this?

RackAdapter itself doesn't have an API for this. You can set :Host using the Rack::Handler interface or you can pass --host when using rackup. 

eNut

unread,
Oct 17, 2011, 9:31:35 PM10/17/11
to Faye users
As of v0.6.6 faye doesn't act in the way you describe. Passing --host
does not give the desired result. I had to hack the faye source and
force it to an address.

Line 48 in faye's rack_adapter.rb is where the problem is I think. It
passes port but no host.

Karl

On Oct 16, 5:55 pm, James Coglan <jcog...@gmail.com> wrote:

James Coglan

unread,
Oct 18, 2011, 6:40:21 AM10/18/11
to faye-...@googlegroups.com
On 18 October 2011 02:31, eNut <kgre...@gmail.com> wrote:
As of v0.6.6 faye doesn't act in the way you describe.  Passing --host
does not give the desired result.  I had to hack the faye source and
force it to an address.

When you use rackup, Faye should not be involved in handling hosts or ports at all -- Rack should be doing this. What does your config.ru file look like?

eNut

unread,
Oct 18, 2011, 8:21:01 AM10/18/11
to Faye users
This is my config.ru:

require 'faye'
bayeux = Faye::RackAdapter.new(:mount => '/framework/push', :timeout
=> 120)bayeux.listen(9293)

Running it like this:

rackup --host 127.0.0.1 faye.ru

Gives me this:

>> Thin web server (v1.2.11 codename Bat-Shit Crazy)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:9293, CTRL+C to stop

And just to be sure, lsof tells me this:

ruby 6328 karl 5u IPv4 0xffffff8022402320 0t0
TCP *:9293 (LISTEN)

So it's not doing something right. If calling rackup with --host
should set it, it doesn't. I'm fairly sure what I did to get it to do
what I wanted was to edit the call in faye I referenced before to
include the option for host. I'll check when I get to work and post
again.

Karl
On Oct 18, 5:40 am, James Coglan <jcog...@gmail.com> wrote:

James Coglan

unread,
Oct 18, 2011, 8:43:03 AM10/18/11
to faye-...@googlegroups.com
On 18 October 2011 13:21, eNut <kgre...@gmail.com> wrote:
require 'faye'
bayeux = Faye::RackAdapter.new(:mount => '/framework/push', :timeout => 120) 
bayeux.listen(9293)

This is the problem: you're starting the server yourself rather than letting rackup do it for you: Instead of 'bayeux.listen(9293)', use 'run bayeux' and pass --port and --host to the rackup command.

eNut

unread,
Oct 18, 2011, 9:23:10 AM10/18/11
to Faye users
That works. Just have to make sure you pass "-s thin" with it.

On Oct 18, 7:43 am, James Coglan <jcog...@gmail.com> wrote:

Евгений Шурмин

unread,
Oct 18, 2011, 11:40:34 AM10/18/11
to faye-...@googlegroups.com
Certainly it works, I but I want to specify it through a code.

      @options[:host] = "192.168.1.2"

      pusher = Faye::RackAdapter.new(:mount => @options[:mount], :timeout => @options[:timeout])
      pusher.add_extension(Extension.new(@options))
      pusher.listen(@options[:port])


2011/10/18 eNut <kgre...@gmail.com>



--
С уважением, Шурмин Евгений

James Coglan

unread,
Oct 18, 2011, 11:51:36 AM10/18/11
to faye-...@googlegroups.com
On 18 October 2011 16:40, Евгений Шурмин <eshu...@gmail.com> wrote:
Certainly it works, I but I want to specify it through a code.

      @options[:host] = "192.168.1.2"

      pusher = Faye::RackAdapter.new(:mount => @options[:mount], :timeout => @options[:timeout])
      pusher.add_extension(Extension.new(@options))
      pusher.listen(@options[:port])


The best way to do this right now is to use Rack. Instead of calling pusher.listen(), which is really just a convenience, use Rack as intended:

thin = Rack::Handler.get('thin')
thin.run(pusher, :Host => '192.168.1.2', :Port => @options[:port])

Евгений Шурмин

unread,
Oct 18, 2011, 2:07:22 PM10/18/11
to faye-...@googlegroups.com
Thanks!
I'm happy! =) 

2011/10/18 James Coglan <jco...@gmail.com>

Hiren Bhalani

unread,
Sep 12, 2017, 3:04:29 AM9/12/17
to Faye users
Reply all
Reply to author
Forward
0 new messages