faye-rails icon indicating copy to clipboard operation
faye-rails copied to clipboard

Using a specific port like 9292

Open Ahmed--Mohsen opened this issue 11 years ago • 7 comments

I am unable to make the server listens on a another port rather than the one that rails server use when I tried the following command:

config.middleware.use FayeRails::Middleware, mount: '/faye', :timeout => 25 do
  listen(9292)  
end

I got the following exception:

/Users/ahmedmohsen/Byte/na_buddy/vendor/bundle/gems/faye-1.0.1/lib/faye/adapters/rack_adapter.rb:40:in `listen': The listen() method is deprecated - see https://github.com/faye/faye-websocket-ruby#running-your-socket-application for information on running your Faye server (RuntimeError)
    from /Users/ahmedmohsen/Byte/na_buddy/vendor/bundle/gems/faye-rails-2.0.0/lib/faye-rails/rack_adapter.rb:16:in `listen'
    from /Users/ahmedmohsen/Byte/na_buddy/config/application.rb:26:in `block in <class:Application>'
    from /Users/ahmedmohsen/Byte/na_buddy/vendor/bundle/gems/faye-rails-2.0.0/lib/faye-rails/middleware.rb:47:in `instance_eval'
    from /Users/ahmedmohsen/Byte/na_buddy/vendor/bundle/gems/faye-rails-2.0.0/lib/faye-rails/middleware.rb:47:in `initialize'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/stack.rb:43:in `new'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/stack.rb:43:in `build'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/stack.rb:118:in `block in build'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/stack.rb:118:in `each'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/stack.rb:118:in `inject'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/stack.rb:118:in `build'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/engine.rb:498:in `app'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/application/finisher.rb:36:in `block in <module:Finisher>'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `run'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/application.rb:288:in `initialize!'
    from /Users/ahmedmohsen/Byte/na_buddy/config/environment.rb:5:in `<top (required)>'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
    from /Users/ahmedmohsen/Byte/na_buddy/config.ru:3:in `block in <main>'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
    from /Users/ahmedmohsen/Byte/na_buddy/config.ru:in `new'
    from /Users/ahmedmohsen/Byte/na_buddy/config.ru:in `<main>'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/server.rb:50:in `app'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/server.rb:130:in `log_to_stdout'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/server.rb:67:in `start'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:81:in `block in server'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `tap'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `server'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Users/ahmedmohsen/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'

Ahmed--Mohsen avatar Aug 28 '14 13:08 Ahmed--Mohsen

+1

clairezed avatar Oct 23 '14 12:10 clairezed

+1

OlegTsarenko avatar Dec 10 '14 10:12 OlegTsarenko

+1

lopezjurip avatar Feb 01 '15 16:02 lopezjurip

+1

jason-hobbs avatar May 14 '15 19:05 jason-hobbs

This was a direct result of decisions made by #44.

jimsynz avatar May 14 '15 22:05 jimsynz

Or a result of upgrading to faye 1.0.0. More: #80.

ciastek avatar Jun 15 '15 13:06 ciastek

I'm not sure whether not able to specify a different port number is the reason for my publish failing but I know with the way my faye is configured as a middleware of rails, I'm not able to successfully publish from my server client.

This is odd because I've been messing with how faye is configured and at one point, the publish was working when I was running faye as a separate process via bundle exec rackup faye.ru -s thin -E production --host 0.0.0.0. my faye.ru had the following:

require 'faye' Faye::WebSocket.load_adapter('thin') faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 45) Faye.logger = lambda { |m| puts m } run faye_server

I also have fayerails gem and have this in my application.rb: config.middleware.delete Rack::Lock config.middleware.use FayeRails::Middleware, mount: '/faye', :timeout => 25

These two seems to be redundant of each other so I removed the faye.rb file completely to let faye be run as a rails middleware. Now I'm not able to successfully publish a message from my server client.

The weird thing is that it's only failing locally. Heroku doesn't seem to mind the middleware approach. Any idea on why?

yanhackcode15 avatar Feb 26 '16 08:02 yanhackcode15