Code Monkey home page Code Monkey logo

faye-rails's Introduction

James's GitHub stats

faye-rails's People

Contributors

aaronjensen avatar bishop avatar chris-teague avatar ciastek avatar endel avatar felixbuenemann avatar flash-gordon avatar gmanley avatar jhicks avatar jimsynz avatar karloku avatar lightyrs avatar linrock avatar mareczek avatar nilbus avatar plukevdh avatar rlovelett avatar roshats avatar ryanscottlewis avatar synthead avatar tardate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

faye-rails's Issues

Error 404 Not Found

Hello. I am using Faye with Rails 3.2.12 to implement comments that are instantly showing up. Everything is working fine, however I get some errors in the Firebug console. When i open the page the POST request is being sent to "http://mydomain.com/faye" with the following response:

[{"id":"1","channel":"/meta/handshake","successful":true,"version":"1.0","supportedConnectionTypes":["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],"clientId":"j1ezqdmr62rap6njeqv7u21kj2nndw1","advice":{"reconnect":"retry","interval":0,"timeout":25000}}]

But right after this appears an error

"NetworkError: 400 Bad Request - http://mydomain.com/faye"

Then another POST request is again sent to the "http://mydomain.com/faye" with reponse like:

[{"id":"2","clientId":"j1ezqdmr62rap6njeqv7u21kj2nndw1","channel":"/meta/subscribe","successful":true,"subscription":"/comments"},{"id":"3","clientId":"j1ezqdmr62rap6njeqv7u21kj2nndw1","channel":"/meta/connect","successful":true,"advice":{"reconnect":"retry","interval":0,"timeout":25000}}]

Then another two errors appears:

Firefox can't establish a connection to the server at ws://mydomain.com/faye.

and

"NetworkError: 404 Not Found - http://mydomain.com/faye/j1ezqdmr62rap6njeqv7u21kj2nndw1/j1ezqdmr62rap6njeqv7u21kj2nndw1"

After these errors follow succesfull POST requests to the "http://mydomain.com/faye" with responses like:

[{"id":"5","clientId":"j1ezqdmr62rap6njeqv7u21kj2nndw1","channel":"/meta/connect","successful":true,"advice":{"reconnect":"retry","interval":0,"timeout":25000}}]

I get all these errors in production (Heroku).

Still the comments are being updated instantly and I detect no other errors or problems.

In my route file I get:

  faye_server '/faye', :timeout => 25

Am I doing something wrong or did I forget something?

Thanks!

XML parser error, probably wrong content type

I am analyzing my production longs and i found this error:

Started POST "/faye" for 200.192.218.141 at 2013-02-14 20:13:16 -0200

REXML::ParseException (The document "message=%5B%7B%22channel%22%3A%22%2Fmeta%2Fsubscribe%22%2C%22clientId%22%3A%22h6z11ybhtmptp6j5seuo9yyh6fp7is6%22%2C%22subscription%22%3A%22%2Fsolicitacoes%2Fedit%22%2C%22id%22%3A%222%22%7D%2C%7B%22channel%22%3A%22%2Fmeta%2Fsubscribe%22%2C%22clientId%22%3A%22h6z11ybhtmptp6j5seuo9yyh6fp7is6%22%2C%22subscription%22%3A%22%2Fmetas%2Fnew%22%2C%22id%22%3A%223%22%7D%2C%7B%22channel%22%3A%22%2Fmeta%2Fsubscribe%22%2C%22clientId%22%3A%22h6z11ybhtmptp6j5seuo9yyh6fp7is6%22%2C%22subscription%22%3A%22%2Fsolicitacoes%2Fnew%22%2C%22id%22%3A%224%22%7D%2C%7B%22channel%22%3A%22%2Fmeta%2Fconnect%22%2C%22clientId%22%3A%22h6z11ybhtmptp6j5seuo9yyh6fp7is6%22%2C%22connectionType%22%3A%22cross-origin-long-polling%22%2C%22id%22%3A%225%22%2C%22advice%22%3A%7B%22timeout%22%3A0%7D%7D%5D" does not have a valid root):

Maybe something with content-type from a Faye transport but i cant figure out, anyone had a problem like that?

erb code not execute on partial after broadcasting

I am using faye rails for a bsic chat. Following the railscast the users can send messages to each other but I want to mark the messages as read when the recepient receives it. I added some ruby code on the partial because I thought that when the message is evaluated on the recipient wil be executed too. But it not working..

application.js:

$(function() {
var faye = new Faye.Client('http://myip/faye');
faye.subscribe('/messages/<%= @conversation.faye_token%>', function (data) {
eval(data);
});
});

create.js.erb:

<% broadcast "/messages/#{@conversation.faye_token}" do %>
$("#chat").append("<%= j(render('message', :message=> @message)) %>");
<% end %>
$('#message_body').val('');

and the partial I am rendering:

<%= message.body %> at <%= message.created_at.strftime("%H:%M, %d %b") %>

<%if message.recipient_id.to_s == session[:user_id].to_s%>
<%message.reading%>
<%end%>

But the ruby code is executed on the recepient only if I reload the whole page.

faye rails duplicate messages after definining the faye.js

I have followed the faye railscast and I have a working chat app. My problem is that chrome gives a 404 error, javascripts/defaults.js not found. I found that the problem was in my application layout:

<%= javascript_include_tag :defaults, "http://myip/faye/faye.js" %>
I changed that with:

<%= javascript_include_tag "application", "http://myip/faye/faye.js" %>

and the error disappeared but when I am sending through my form the message it creates and broadcasts a duplicate record of the message.

If more information needed plz ask, I am not sure which part of my code to include in the question.

Faye.ensure_reactor_running! in an initializer

Hi, I noticed your recent change to the README in which you recommended an initializer to run Faye.ensure_reactor_running!. I've actually tried this before with no luck. When I try to start a server in development mode, it just exits during the app startup like so.

$ rails server
=> Booting Thin
=> Rails 4.0.0.beta application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.0 codename Knife)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
Exiting

Have you gotten ensure_reactor_running! working in one of your own apps?

Issue with Sidekiq/foreman combo

I'm trying to setup an app using faye-rails, but running into a problem whilst using it with Sidekiq.

In routes.rb I have the following :

faye_server "/faye", timeout: 45 do
    listen(9090)
end

Pretty simple and straight forward, but my issue is that, when sidekiq runs, this command gets triggerd, and starts up an instance of faye. Then my app runs and does it again, which needless to say causes an error when thin complains about the port being in use.

Is there any nice way of getting around this?

Observers not loaded and triggered

I have a standard rails app running on thin, and I have a "realtime" FayeController for each of my models under /app/realtime. I added this directory to my config.autoload path, but the observer isn't called or loaded unless I go to the rails console and type the name of the observer to load it (e.g. For /app/realtime/posts_realtime.rb, I type "PostsRealtime").

Since FayeController doesn't inherit from ActiveRecord::Observer (another thought...), I can't load the observer via config.active_record_observers. What is the preferred way to load the controller so that observers get triggered? Doing a require is hacky.

Here's the controller/observer:

class PostsRealtime < FayeRails::Controller
    observe Post, :after_create do |post|
        PostsRealtime.publish "/posts/create", post.attributes
        Rails.logger.info "-----------------JUST CREATED--------------------"
    end

    observe Post, :after_update do |post|
        PostsRealtime.publish "/posts/#{post.id}/update", post.attributes
    end

    observe Post, :after_destroy do |post|
        PostsRealtime.publish "/posts/#{post.id}/destroy"
    end
end

~ Jonathan

Interference with DelayedJob? No Acceptor

EDIT: no longer thing it has to do with delayed_job necessarily, though the errors were different when I used it. Here's my procfile btw:

web: bundle exec thin start -p $PORT
worker: bundle exec rake --trace jobs:work ENV=development
log: tail -f -n 0 log/development.log

If I try and run faye-rails (listening on any number of ports) and run delayed_job (using bundle exec rake --trace jobs:work) I get this:

>> Thin web server (v1.4.1 codename Chromeo)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:2000, CTRL+C to stop
rake aborted!
no acceptor
/.rvm/gems/ruby-1.9.3-p0@2u/gems/eventmachine-0.12.10/lib/eventmachine.rb:572:in `start_tcp_server'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/eventmachine-0.12.10/lib/eventmachine.rb:572:in `start_server'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/thin-1.4.1/lib/thin/backends/tcp_server.rb:16:in `connect'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/thin-1.4.1/lib/thin/backends/base.rb:55:in `block in start'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/thin-1.4.1/lib/thin/backends/base.rb:61:in `call'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/thin-1.4.1/lib/thin/backends/base.rb:61:in `start'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/thin-1.4.1/lib/thin/server.rb:159:in `start'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/faye-0.8.5/lib/faye/adapters/rack_adapter.rb:54:in `listen'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/faye-rails-1.0.1/lib/faye-rails/rack_adapter.rb:16:in `listen'
/Sites/fusefm/config/routes.rb:8:in `block (2 levels) in <top (required)>'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/faye-rails-1.0.1/lib/faye-rails/routing_hooks.rb:27:in `instance_eval'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/faye-rails-1.0.1/lib/faye-rails/routing_hooks.rb:27:in `faye_server'
/Sites/fusefm/config/routes.rb:5:in `block in <top (required)>'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:260:in `draw'
/Sites/fusefm/config/routes.rb:1:in `<top (required)>'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `load'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `block in load'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `load'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:40:in `each'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:16:in `reload!'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/activesupport-3.2.6/lib/active_support/file_update_checker.rb:78:in `call'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/activesupport-3.2.6/lib/active_support/file_update_checker.rb:78:in `execute'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:27:in `updater'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `instance_exec'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `run'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `each'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `run_initializers'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application.rb:136:in `initialize!'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Sites/fusefm/config/environment.rb:5:in `<top (required)>'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application.rb:103:in `require_environment!'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/railties-3.2.6/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/.rvm/gems/ruby-1.9.3-p0@2u/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/.rvm/gems/ruby-1.9.3-p0@2u/bin/rake:19:in `load'
/.rvm/gems/ruby-1.9.3-p0@2u/bin/rake:19:in `<main>'
Tasks: TOP => jobs:work => environment
>> Thin web server (v1.4.1 codename Chromeo)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:5100, CTRL+C to stop
exited with code 1

If I remove the delayed_job worker I get:

>> Thin web server (v1.4.1 codename Chromeo)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:2000, CTRL+C to stop
>> Thin web server (v1.4.1 codename Chromeo)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:5000, CTRL+C to stop
exited with code 0

Any reason why it just exits like this?

`config.threadsafe!` needed with pre-4 Rails

I don't know what the backwards support policy is for faye-rails, but in pre-4 Rails, but I have an issue in latest Rails 3.x when running the application. I'm using latest thin and faye-rails and I get the following error:

!! Unexpected error while processing request: deadlock; recursive locking

This appears to be an issue with Faye from this issue report: faye/faye#190. I get this issue running locally however, not on Heroku. The resolution is to add config.threadsafe! to my application.rb. This would be a great caveat to have listed or a solution to be added to the gem. I believe Rails 4 solves this problem by removing the Rack::Lock middleware which seems to be the core of the issue. Still be nice to have this issue listed with a potential solve.

Using Redis - [ERROR] [FayeRails::RackAdapter] Use pubsub client

I'm trying to setup the redis engine in rails 3.2, the rest of the app is working pretty good. I've run into a few things where I get a >= 100 error from Rack::Lint, but that's why you're supposed to run in production. Anyways.. I've followed @nilbus and the doc's advice for setting up Redis engine. Here's what's in my routes.rb

faye_server '/faye', :timeout => 25, :engine => { :type => Faye::Redis, :host => 'localhost'} do
  map '/*' => RealTimeController
  map :default => :block
end

Note: I've added faye-redis to my Gemfile, and the class is included when I checked rails console.

1.9.3p374 :001 > Faye::Redis
 => Faye::Redis

But when I run thin, even with production, it gives this nasty backtrace and a very ambiguous error (just after a get request).

Started GET "/faye" for 127.0.0.1 at 2013-05-01 10:02:47 -0600
2013-05-01 10:02:47 [ERROR] [FayeRails::RackAdapter] Use pubsub client
Backtrace:
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/em-hiredis-0.2.1/lib/em-hiredis/client.rb:54:in `subscribe'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-redis-0.1.0/lib/faye/redis.rb:47:in `init'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-redis-0.1.0/lib/faye/redis.rb:97:in `client_exists'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/server.rb:184:in `connect'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/server.rb:116:in `handle_meta'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/server.rb:91:in `handle'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/server.rb:67:in `block (2 levels) in process'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/extensible.rb:30:in `call'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/extensible.rb:30:in `block in pipe_through_extensions'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-rails-1.0.6/lib/faye-rails/rack_adapter.rb:113:in `call'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-rails-1.0.6/lib/faye-rails/rack_adapter.rb:113:in `incoming'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/extensible.rb:33:in `block in pipe_through_extensions'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/extensible.rb:38:in `call'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/extensible.rb:38:in `pipe_through_extensions'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/server.rb:66:in `block in process'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/server.rb:65:in `each'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/protocol/server.rb:65:in `process'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-0.8.8/lib/faye/adapters/rack_adapter.rb:143:in `block in handle_websocket'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-websocket-0.4.6/lib/faye/websocket/api/event_target.rb:24:in `call'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-websocket-0.4.6/lib/faye/websocket/api/event_target.rb:24:in `dispatch_event'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-websocket-0.4.6/lib/faye/websocket/api.rb:45:in `receive'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-websocket-0.4.6/lib/faye/websocket/hybi_parser.rb:260:in `emit_frame'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-websocket-0.4.6/lib/faye/websocket/hybi_parser.rb:125:in `parse'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-websocket-0.4.6/lib/faye/websocket.rb:172:in `parse'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-websocket-0.4.6/lib/faye/websocket.rb:202:in `receive'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/faye-websocket-0.4.6/lib/faye/adapters/thin.rb:46:in `receive_data'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/thin-1.5.0/lib/thin/backends/base.rb:63:in `start'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/thin-1.5.0/lib/thin/server.rb:159:in `start'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.5/lib/rack/handler/thin.rb:13:in `run'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.5/lib/rack/server.rb:268:in `start'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.12/lib/rails/commands.rb:55:in `block in <top (required)>'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
/Users/film42/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'

So, after much googling, I'm stuck with this issue and no solution. Any thoughts?

UPDATE: I used induction to check to see what redis was holding and low and behold, I found data from Faye. So that error is specifically an issue with subscribing then.

rake aborted! eventmachine not initialized: evma_install_oneshot_timer

Rails 4.2.0
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
thin 1.6.3

I got this error when creating/saving observed model in rake db:seed or in console. I have this in config/initializers/faye.rb
I don't know where else do I need to check.

def running_as_server?
  Rails.const_defined?('Server') || defined?(::Rack::Handler::Thin)
end

Rails.application.config.after_initialize do
  unless running_as_server?
    puts "--Faye.ensure_reactor_running!"
    Faye.ensure_reactor_running!
  end
end

and in config/application.rb

config.middleware.delete Rack::Lock
config.middleware.use FayeRails::Middleware, mount: '/quick', :timeout => 25 do
    map '/registerapp/**' => ManageTabletsController
      # ... more mappings
      map :default => :block
    end

and in ManageTabletsController

class ManageTabletsController < FayeRails::Controller
  observe Device, :after_save do |r|
    #some code
  end
end

Error: Could not find a usable connection type for /faye

Versions: Ruby 1.9.3, Thin 1.5.1, Rails 3.2.13, FayeRails 1.0.11, Faye 0.8.9

Chrome 29:
Uncaught TypeError: Cannot read property 'JSON' of undefined

Firefox 23.0.1:
this is undefined

Safari 6.0.5:
'undefined' is not an object (evaluating 'this.JSON')

Summary:
'this' seems to be undefined in faye.js resulting in:
Error: Could not find a usable connection type for /faye

Found a corresponding fix here:
faye/faye@1ee9e59

Routes file seemingly not working

Hi,

I've the following in my routes.rb:

faye_server '/faye', timeout: 25 do
  map '/find/*' => ApiController
end

and then I've the api controller as follows (snippet):

class ApiController < FayeRails::Controller
  channel '/find/*' do
    subscribe do
      Rails.logger.debug "In Subscribe"
      ...
      ApiController.publish(channel, some_other_data)
    end
  end
end

I'm connecting fine, but any publish function client side to say /faye/find/1 just returns the data posted with it, and the debug call there never happens.

I've tried removing the the wildcard and replacing it with a fixed integer like 1, still the same.
Is there something I'm missing? Terminal isn't complaining and since it connects fine and does echo back, I'm pretty sure its mostly correct, any ideas?

Handshake fails - routing error

While handshaking with a Java Client,I get an 404 error
ActionController::RoutingError (No route matches [POST] "/faye/handshake")

The client works with the current faye version usingrackup/thin

Server stop listening after a while

Hey there!

I initialize everything link you do on your example:

  faye_server '/hub', timeout: 25 do
    listen(9292)
    map '/solids/*' => RealtimeSolidsController
    map default: :block
  end

The thing is, after a night without visiting the website, when I try to reach /hub, nothing happen. Just like it stopped to listen, or maybe the faye server is down?

An other thing. I listen on 9292 because I want to be able to reach the faye server from a mobile client. When I don't set run listen(9292), I don't know what is the endpoint for the faye server. Can you explain me if that's possible? :)

Thank you and awesome job with the Gem :)

Jeremy

Can I get a response from client side?

Hello,

I want to take some data on server side (RoR with faye-rails) from client side (Ruby + faye client). The problem is that the client is behind a firewall and because of it, I connecting client to server and wait for any command from it. Client can publish back to channel all requested data but I can't understand how I can take back this message in the server controller after publishing request to client channel.

This is the controller action:

def send_request
    require 'net/http'
    publication = ClientController.publish("/client", params[:query])
    publication.callback do
            @res "[PUBLISH SUCCEEDED]"
    end
    publication.errback do |error|
            @res = "[PUBLISH FAILED] #{error.inspect}"
    end
end

How I can take a response from client in the usual controller?

Thanks a lot.

callback.call(message) extension problem

I have problem with callback.call(message). First my code:

application.rb

    config.middleware.delete Rack::Lock
    config.middleware.use FayeRails::Middleware, mount: '/faye', :timeout => 25 do
      map '/realtime_events/*' => RealtimeEventsController
      map :default => :block

      add_extension(RealtimeAuth.new)
    end

realtime_auth.rb

class RealtimeAuth
  def incoming(message, callback)
    puts "---- INCOMING ----"
    puts message.inspect
    if message['channel'] == '/meta/subscribe'
      puts "SUBSCRIBE CHANNEL"
      # my authentication logic
    else
      puts "OTHER CHANNEL"
      callback.call(message)
    end
  end

  def outgoing(message, callback)
    puts "---- OUTGOING ----"
    puts message.inspect
    callback.call(message)
  end
end

Whe i try to publish message to realtime_events channel i got this:

---- INCOMING ----
{"channel"=>"/realtime_events/2", "data"=>{:type=>"chat_invitation", :thread_id=>4, :sender_id=>13, :sender_name=>"johnny"}, "clientId"=>"dh3gi504ylm9z72otofwnv6fqpsr55c", "id"=>"2"}
OTHER CHANNEL

---- OUTGOING ----
{"id"=>"2", "channel"=>"/realtime_events/2", "successful"=>true}

Outgoing message don't have data field
but when i change RealtimeAuth incoming function to this:

 def incoming(message, callback)
    puts "---- INCOMING ----"
    puts message.inspect
    if message['channel'] == '/meta/subscribe'
      puts "SUBSCRIBE CHANNEL"
      # my authentication logic
    end
    puts "OTHER CHANNEL"
    callback.call(message)
  end

Everything works:

---- INCOMING ----
{"channel"=>"/realtime_events/2", "data"=>{:type=>"chat_invitation", :thread_id=>4, :sender_id=>13, :sender_name=>"johnny"}, "clientId"=>"b07yf7b1nbuorqqeoj5jh0efow2uf6f", "id"=>"2"}
OTHER CHANNEL

---- OUTGOING ----
{"channel"=>"/realtime_events/2", "data"=>{:type=>"chat_invitation", :thread_id=>4, :sender_id=>13, :sender_name=>"johnny"}, "id"=>"2"}

Can someone explain why this don't work as expected? Thanks for help.

"eventmachine not initialized: evma_connect_to_server" in background jobs

I have a problem where a background job triggers the observer in my FayeRails::Controller which calls self.publish(), but it fails when trying to connect to the server.

I am initializing Faye-Rails in the routes file.

How should things be initialized for background jobs that don't run under Thin?

Model observer - wrong constant name

Hi. I have problem with setting model observer for my Message model. My Faye cotroller:

app/realtime/realtime_message_controller.rb

class RealtimeMessageController < FayeRails::Controller
  observe Message, :after_create do |msg|
    RealtimeMessageController.publish('/messages/new', msg.attributes)
  end
end

config/application.rb

 config.middleware.delete Rack::Lock
 config.middleware.use FayeRails::Middleware, mount: '/faye', :timeout => 25 do
   map '/messages/new' => RealtimeMessageController
   map :default => :block
 end

When i try to start app, i get this error:

faye-rails-2.0.0/lib/faye-rails/controller/observer_factory.rb:17:in 
`const_set': wrong constant name FayeRails::Controller::MessageCallbacks (NameError)

Ruby 2.2.0
Rails 4.2.0

Thanks for help

User's online status

Hi, I am using private_pub gem to configure faye in my applicaiton.

# private_pub.ru

# Run with: rackup private_pub.ru -s thin -E production
require "bundler/setup"
require "yaml"
require "faye"
require "private_pub"

# Only load rails environment if required
# we are calling sidekiq so it is required
require ::File.expand_path('../config/environment',  __FILE__)

Faye::WebSocket.load_adapter('thin')

PrivatePub.load_config(File.expand_path("../config/private_pub.yml", __FILE__), ENV["RAILS_ENV"] || "development")
# run PrivatePub.faye_app



# UPDATED CODE - 
# added functionality in gem
app = PrivatePub.faye_app

# subscribe - online
app.bind(:subscribe) do |client_id, channel|
  puts "Client subscribe: #{client_id}:#{channel}"

  if /\/user\/*/.match(channel)
    p "ok ****8"
    SubscribeClient.perform_async(client_id, channel)
  end
end

# unsubscribe - offline
app.bind(:unsubscribe) do |client_id, channel|
  puts "Client unsubscribe: #{client_id}:#{channel}"
  UnsubscribeClient.perform_async(client_id)
end

# disconnect - offline
app.bind(:disconnect) do |client_id|
  puts "Client disconnect: #{client_id}"
  UnsubscribeClient.perform_async(client_id)
end

run app

PROBLEM

Now, my problem is, when I close browser or browser tab where my app is running, the disconnect event fires up:

e.g:

    # console log
    Client disconnect: 7q30kyezc4d68kjnyuik9quw42tqk2u
  1. But when did subscribe and unsubscribe events trigger? unsubscribe is not triggering when I close browser / tab. Only disconnect is triggered.
  2. Also, when is subscribe triggered? When I reconnect to application again, it is not triggering.

What I want now is, When user disconnect from the app, I will update that user to offline mode and if he come back to application, I have to update him to online mode again.....How can I acheive this??

Private channel functionality.

I'd like to add an API for private channel functionality, tied to a specific session. I'm really open to suggestions from people for how to implement this, and as such am inviting all previous collaborators (@RLovelett @endel @tardate @nilbus @gmanley @mareczek @linrock @jhicks @RyanScottLewis @aaronjensen) to pipe in with ideas and opinions.

So, I'm thinking of something like this:

class SomePageController < ApplicationController
  before_filter do
    authorize_private_channel for: current_user, as: :current_user, using_controller: PrivateChannelController
  end
end

Where the authorize_private_channel will create a unique token to be inserted into the page much like the CSRF token is now. We'll probably have to write a simple JS client library to handle automatic subscription to this private channel when the token is present.

The for: argument can be an arbitrary Ruby object that is passed into scope of the channel and observer DSLs as a way to uniquely identify which particular private channel we're talking about.

The as: argument is used to name the context object in the DSL, so in the example above it will be available as current_user inside the DSL methods.

The using_controller: argument maps the private channel to a particular controller. The controller is the same as any other FayeRails::Controller subclass, except that it is given a special filter which only allows a user with the correct single-use token to subscribe and publish.

This is about the best API I can come up with off the top of my head - has anyone else any ideas?

Thanks!

Routes

Inside my route I have

faye_server '/faye', timeout: 25

When I run rake routes

                faye        /faye(.:format)                #<FayeRails::RackAdapter:0x007fd082f50140 @options={:mount=>"/faye", :timeout=>25, :engine=>nil}, @endpoint="/faye", @endpoint_re=/^\/faye(\/[^\/]+)*(\.[^\.]+)?$/, @server=#<Faye::Server:0x007fd082f4ff60 @options={:mount=>"/faye", :timeout=>25, :engine=>nil}, @engine=#<Faye::Engine::Proxy:0x007fd082f4ff10 @options={:timeout=>25}, @connections={}, @interval=0.0, @timeout=25, @engine=#<Faye::Engine::Memory:0x007fd082f4fec0 @server=#<Faye::Engine::Proxy:0x007fd082f4ff10 ...>, @options={:timeout=>25}, @namespace=#<Faye::Namespace:0x007fd082f4fe98 @used={}>, @clients={}, @channels={}, @messages={}>>>, @static=#<Faye::StaticServer:0x007fd082f4fd30 @directory="/Users/ryan/.rvm/gems/ruby-1.9.3-p194@rpc-demo/gems/faye-0.8.2/lib", @path_regex=/\.(?:js|map)$/, @path_map={"faye.js"=>"faye-browser-min.js", "client.js"=>"faye-browser-min.js"}, @index={}>>

When I go to http://localhost:3000/faye/client.js I encounter a routing error.

I am using Rails 3.2.3.

Any tips or tricks would be appreciated.

App very slow on production, works fine on development

Hello,

Before using this gem I was running two processes to run faye (faye on port 4001). The application was working fine on development and on the production. I wanted to move both to one process, so I found this gem and included it in my app. Everything was working fine on development. But on production the app got very very slow, it needed one minute to load and about 20 seconds to make one pub-sub action (before it worked without any delay).

What is wrong and how to fix it?

Thanks,
Joanna

Can not configure model observer

Hello. I am trying to make an applications with faye-rails 1.0.7. (with model observers)

I created observer controller RealtimePublicationsController (in app/realtime) with:

  observe Publication, :after_create do |publication|
    RealtimePublicationsController.publish('/publications', "OK")
  end

Some test clientside JS code:


client = new Faye.Client('/faye')
client.subscribe '/publications', (payload)->
  console.log "Client subscribe"

Route.rb:


  resources :publications
  faye_server '/faye', timeout: 25 do
    map '/publications' => RealtimePublicationsController
    map default: :block
  end

After that i start console and write Publication.create({:title => "test"}), and ... get nothing in browser console.
What i am doing wrong? Help, please...

Rails 4 compatibility (without breaking Rails 3.2)

Raising for discussion of how to handle Rails 4 compatibility as a result of #24.

My suggestion (as is @jcoglan's) is to stop using the Rails router to send messages through to Faye because each connection brings along the whole middleware stack (ie Rack::Lock, etc) - this has caused a bunch of problems; #30, #35, #37 to name a few.

Instead, the faye_server method should insert the Faye rack app as a middleware in the middleware chain. This should avoid pretty much all rails-related problems. Discussions on how to do this?

/cc @nilbus @RLovelett @lvanderhoeven

Passenger support is broken

It seems that this condition was deleted during merge (0773e00) from middleware.rb:

Faye::WebSocket.load_adapter(server) if server && server != 'passenger'

So it tries to load passenger adapter, but it doesn't exist.

Channel wildcard using FayeRails::Controller

I need to do something like this:

class WidgetController < FayeRails::Controller
  channel '/widgets/**' do
    monitor :subscribe do
      # This callback never works
    end
  end

  channel '/widgets/1' do
    monitor :subscribe do
      # This one works fine
    end
  end
end

I've read the docs and didn't found if that is possible. Looking through the class FayeRails::Controller::Channel, it seems that channels can only be hardly defined, like '/widgets/1', isn't it?

If I mapping a channel with wildcard on Rails routes is possible, why I can't on the Controller's channel definition?
Thanks for the attention.

null byte in message's channel

FayeRails::RackAdapter::RoutingExtension#incoming uses File.fnmatch? to match channel name. If channel name contains null byte "\0" an ArgumentError would be raised. The exception will drop a server (checked with Thin and Webric).
faye-browser.js includes channels names at 928..932 lines, malefactor can add null byte to channel name here via fire bug.

faye-browser-min.js.map causing rails asset pipeline compilation failure

NB: raising this issue as a result of conversation here: #13 (comment)

with faye-browser-min.js.map included, rails asset pipeline compilation calls me a punk and fails with a syntax error. Remove this file, and it works.

# in a rails project that adds the faye-rails gem...
$ bundle exec rake assets:precompile
/Users/me/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /Users/me/.rvm/gems/ruby-1.9.2-p290@global/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
Unexpected token: punc (:)
(in /Users/me/faye-rails/vendor/assets/javascripts/faye-browser-min.js.map)

Tasks: TOP => assets:precompile:primary
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1)

I'm actually not familiar with what this map file is used for, But I think the core of this issue is the question of what we expect to do with /vendor/assets. It seems they should be excluded from precompilation, and the non-minified and .map files are only there for debug/development use (and not automatically included in the assets served by the client).

FayeRails.server nil in production

When Rails eager-loads my Faye controller, FayeRails.server(endpoint) is returning nil in the production environment, which prevents the server from starting.

/home/nilbus/.bundler/ruby/1.9.1/faye-rails-72639229f67e/lib/faye-rails/controller/channel.rb:23:in `monitor': undefined method `bind' for nil:NilClass (NoMethodError)
    from /home/nilbus/Dropbox/git/pinewood-derby/app/controllers/announce_controller.rb:35:in `block in <class:AnnounceController>'
    from /home/nilbus/.bundler/ruby/1.9.1/faye-rails-72639229f67e/lib/faye-rails/controller.rb:34:in `instance_eval'
    from /home/nilbus/.bundler/ruby/1.9.1/faye-rails-72639229f67e/lib/faye-rails/controller.rb:34:in `channel'
    from /home/nilbus/Dropbox/git/pinewood-derby/app/controllers/announce_controller.rb:34:in `<class:AnnounceController>'
    from /home/nilbus/Dropbox/git/pinewood-derby/app/controllers/announce_controller.rb:1:in `<top (required)>'
    from /home/nilbus/Dropbox/git/rails/activesupport/lib/active_support/dependencies.rb:228:in `require'
    ...
    from /home/nilbus/Dropbox/git/rails/railties/lib/rails/engine.rb:466:in `block (2 levels) in eager_load!'

The relevant part of my AnnounceController:

class AnnounceController < FayeRails::Controller
  channel '/announce' do
    monitor :publish do
      ApplicationHelper.log "Client #{client_id} published #{data.inspect} to #{channel}."
    end
  end
end

The line below in channel.rb is where the traceback is thrown from.

    FayeRails.server(endpoint).bind(event) do |*args|

I'm unsure whether or not this is related to Rails 4.

Is this working in other apps in the production environment?

faye with proxy which require auth

In case when internet via proxy with auth, my site get 407 error (proxy auth failed). Can I pass to faye http headers that solved this problem?

Tests isn't passing

Hey James,

I've just cloned your repo and most specs isn't passing.
Also can't get a simple Rails app with your binding running.

Can you give a example of real Rails app running using it?

Thanks

Observer does not seem to work

Using example:

class WidgetController < FayeRails::Controller
  observe Widget, :create do |new_widget|
    publish('/widgets', new_widget.attributes)
  end
end

I get this error:

undefined method `publish' for WidgetController:Class

Weird delay when publishing on a different thread.

I'm really liking faye-rails, so great job!

I do seem to have run into a weird situation. I want to run a simple query and publish every second to all clients. Adding a loop to the main thread will obviously cause it to choke and halt the app.

So I shoved it in a new thread like this:

Thread.new do
  loop do
    tweet = Tweet.last
    RealTimeController.publish("/tweets/new", tweet)
    sleep 1
  end
end

The only problem now is that faye-rails' publish is not immediately publishing to the clients. It's storing in some queue and will send multiple requests over at once. In other words.. a massive delay. I can also poke it from the client like so:

client.publish('/tweets/new', {text: "unblock"});

When I run this, I can see the faye realize there are other things in the queue and sends them all over. So is this just me not understanding how to send a publish request on a different thread? Also, an observer won't be useful here as all db writing is performed in a different app. Any light on the matter would be amazing. Thanks! :)

Rename internal classes so that they're prefixed with Faye

So, for example, Channel would be renamed to FayeChannel, Message would be renamed to FayeMessage, etc.

This would make it much harder for classes like Channel and Message to collide with user-defined models, and considering how they're mostly used internally, it shouldn't be too much of a problem to rename them.

REXML::ParseExeption (The document "***" does not have a valid root) on callback-polling

When I try to connect with an Android browser, the following error appears:

REXML::ParseException (The document "message=%5B%7B%22channel%22%3A%22%2Fmeta%2Fsubscribe%22%2C%22clientId%22%3A%2254rzpsncv4pe01od07wfapg0td4gzat%22%2C%22subscription%22%3A%22%2Fwaitinglist%2Fupdate%22%2C%22id%22%3A%223%22%7D%5D" does not have a valid root):
  activesupport (3.2.11) lib/active_support/xml_mini/rexml.rb:35:in `parse'
  activesupport (3.2.11) lib/active_support/xml_mini.rb:80:in `parse'
  activesupport (3.2.11) lib/active_support/core_ext/hash/conversions.rb:98:in `from_xml'
  actionpack (3.2.11) lib/action_dispatch/middleware/params_parser.rb:41:in `parse_formatted_parameters'
  actionpack (3.2.11) lib/action_dispatch/middleware/params_parser.rb:17:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
  rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/cookies.rb:341:in `call'
  activerecord (3.2.11) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `_run__2790425369923233704__call__4262545661994225693__callbacks'
  activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.11) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.11) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.11) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.11) lib/rails/rack/logger.rb:16:in `block in call'
  activesupport (3.2.11) lib/active_support/tagged_logging.rb:22:in `tagged'
  railties (3.2.11) lib/rails/rack/logger.rb:16:in `call'
  quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
  actionpack (3.2.11) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:in `call'
  railties (3.2.11) lib/rails/engine.rb:479:in `call'
  railties (3.2.11) lib/rails/application.rb:223:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  railties (3.2.11) lib/rails/rack/log_tailer.rb:17:in `call'
  thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process'
  thin (1.5.1) lib/thin/connection.rb:79:in `catch'
  thin (1.5.1) lib/thin/connection.rb:79:in `pre_process'
  thin (1.5.1) lib/thin/connection.rb:54:in `process'
  faye-websocket (0.4.7) lib/faye/adapters/thin.rb:41:in `process'
  thin (1.5.1) lib/thin/connection.rb:39:in `receive_data'
  faye-websocket (0.4.7) lib/faye/adapters/thin.rb:45:in `receive_data'
  eventmachine (1.0.3) lib/eventmachine.rb:187:in `run_machine'
  eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
  thin (1.5.1) lib/thin/backends/base.rb:63:in `start'
  thin (1.5.1) lib/thin/server.rb:159:in `start'
  rack (1.4.1) lib/rack/handler/thin.rb:13:in `run'
  rack (1.4.1) lib/rack/server.rb:265:in `start'
  railties (3.2.11) lib/rails/commands/server.rb:70:in `start'
  railties (3.2.11) lib/rails/commands.rb:55:in `block in <top (required)>'
  railties (3.2.11) lib/rails/commands.rb:50:in `tap'
  railties (3.2.11) lib/rails/commands.rb:50:in `<top (required)>'
  script/rails:8:in `require'
  script/rails:8:in `<main>'

When using just Faye the phone can just connect.. Disabling callback-longpolling makes all connection types unusable, so it has to be callback-longpolling creating the error here..

Using Ruby 1.9.3 & Rails 3.2.11

Using a specific port like 9292

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)>'

faye-browser-min.js.map on faye-rails (1.0.6)

While using Faye-rails time after time i get this error. Where is importing this file?

ActionController::RoutingError (No route matches [GET] "/assets/faye-browser-min.js.map"):
actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:21:in call' actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:incall'
railties (3.2.11) lib/rails/rack/logger.rb:32:in call_app' railties (3.2.11) lib/rails/rack/logger.rb:16:inblock in call'
activesupport (3.2.11) lib/active_support/tagged_logging.rb:22:in tagged' railties (3.2.11) lib/rails/rack/logger.rb:16:incall'
actionpack (3.2.11) lib/action_dispatch/middleware/request_id.rb:22:in call' rack (1.4.5) lib/rack/methodoverride.rb:21:incall'
rack (1.4.5) lib/rack/runtime.rb:17:in call' activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:incall'
actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:in call' railties (3.2.11) lib/rails/engine.rb:479:incall'
railties (3.2.11) lib/rails/application.rb:223:in call' rack (1.4.5) lib/rack/content_length.rb:14:incall'
railties (3.2.11) lib/rails/rack/log_tailer.rb:17:in call' thin (1.5.0) lib/thin/connection.rb:81:inblock in pre_process'
thin (1.5.0) lib/thin/connection.rb:79:in catch' thin (1.5.0) lib/thin/connection.rb:79:inpre_process'
thin (1.5.0) lib/thin/connection.rb:54:in process' faye-websocket (0.4.6) lib/faye/adapters/thin.rb:41:inprocess'
thin (1.5.0) lib/thin/connection.rb:39:in receive_data' faye-websocket (0.4.6) lib/faye/adapters/thin.rb:45:inreceive_data'
eventmachine (1.0.0) lib/eventmachine.rb:187:in run_machine' eventmachine (1.0.0) lib/eventmachine.rb:187:inrun'
thin (1.5.0) lib/thin/backends/base.rb:63:in start' thin (1.5.0) lib/thin/server.rb:159:instart'
rack (1.4.5) lib/rack/handler/thin.rb:13:in run' rack (1.4.5) lib/rack/server.rb:268:instart'
railties (3.2.11) lib/rails/commands/server.rb:70:in start' railties (3.2.11) lib/rails/commands.rb:55:inblock in <top (required)>'
railties (3.2.11) lib/rails/commands.rb:50:in tap' railties (3.2.11) lib/rails/commands.rb:50:in<top (required)>'
script/rails:6:in require' script/rails:6:in<top (required)>'
-e:1:in load' -e:1:in

'

Rendered /usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.0ms)

Rack application could not be started

It seems that I sometimes get this message, and other times it starts up fine. Any ideas would be appreciated.

I'm running on nginx and passenger, and have faye running on 4443 in my routes file.

Error message:
no acceptor

Exception class:
RuntimeError

Application root:
/home/shoptracker/src/shoptracker/current

Backtrace:
0   /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb    572 in `start_tcp_server'
1   /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb    572 in `start_server'
2   /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/backends/tcp_server.rb  16  in `connect'
3   /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/backends/base.rb    53  in `block in start'
4   /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/backends/base.rb    59  in `call'
5   /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/backends/base.rb    59  in `start'
6   /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/server.rb   159 in `start'
7   /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/handler/thin.rb 13  in `run'
8   /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/faye-0.8.2/lib/faye/adapters/rack_adapter.rb    54  in `listen'
9   /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/faye-rails-1.0.0/lib/faye-rails/rack_adapter.rb 16  in `listen'
10  /home/shoptracker/src/shoptracker/releases/20120703040944/config/routes.rb  3   in `block (2 levels) in '
11  /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/faye-rails-1.0.0/lib/faye-rails/routing_hooks.rb    27  in `instance_eval'
12  /home/shoptracker/src/shoptracker/shared/bundle/ruby/1.9.1/gems/faye-rails-1.0.0/lib/faye-rails/routing_hooks.rb    27  in `faye_server'
13  /home/shoptracker/src/shoptracker/releases/20120703040944/config/routes.rb  2   in `block in '

faye.js throws 404, no error given.

Exact same problem as issue#7, followed the tutorial, but still cannot fix it. Even cloned the repo and rackup'd the "dummy" app under spec, still cannot grab faye.js or any similarly named file. No errors reported (besides the 404), cannot figure this out. Ran bundle install twice, shows up fine in rake routes but 404 every time.

This is the last line of my "rake routes" output

faye ALL        /faye(.:format)                           #<FayeRails::RackAdapter:0x00000104bb0b20 @options={:mount=>"/faye", :timeout=>25, :extensions=>nil, :engine=>nil, :ping=>nil}, @endpoint="/faye", @endpoint_re=/^\/faye(\/[^\/]+)*(\.[^\.]+)?$/, @server=#<Faye::Server:0x00000104bb0968 @options={:mount=>"/faye", :timeout=>25, :extensions=>nil, :engine=>nil, :ping=>nil}, @engine=#<Faye::Engine::Proxy:0x00000104bb0918 @options={:timeout=>25}, @connections={}, @interval=0.0, @timeout=25, @engine=#<Faye::Engine::Memory:0x00000104bb08c8 @server=#<Faye::Engine::Proxy:0x00000104bb0918 ...>, @options={:timeout=>25}, @namespace=#<Faye::Namespace:0x00000104bb08a0 @used={}>, @clients={}, @channels={}, @messages={}>, @subscribers={:disconnect=>[#<Proc:0x00000104bb07b0@/usr/local/rvm/gems/ruby-1.9.3-p194/gems/faye-0.8.8/lib/faye/engines/proxy.rb:48>]}>>, @static=#<Faye::StaticServer:0x00000104bb0698 @directory="/usr/local/rvm/gems/ruby-1.9.3-p194/gems/faye-0.8.8/lib", @path_regex=/\.(?:js|map)$/, @path_map={"faye.js"=>"faye-browser-min.js", "client.js"=>"faye-browser-min.js"}, @index={}>>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.