webster
webster

Reputation: 4032

Faye server not working

I am trying out the railscast episode of private_pub gem. I am not able run the faye server.

After running this command:

rackup private_pub.ru -s thin -E production

I am getting the following error:

/home/rhh/railscast_episodes/railscasts-episodes/episode-316/chatter-after/private_pub.ru:4:in `require': /home/rhh/.rvm/gems/ruby-2.0.0-p481/gems/faye-0.7.1/lib/faye.rb:54: too short escaped multibyte character: /^([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$/ (SyntaxError)
    from /home/rhh/railscast_episodes/railscasts-episodes/episode-316/chatter-after/private_pub.ru:4:in `block in <main>'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
    from /home/rhh/railscast_episodes/railscasts-episodes/episode-316/chatter-after/private_pub.ru:1:in `new'
    from /home/rhh/railscast_episodes/railscasts-episodes/episode-316/chatter-after/private_pub.ru:1:in `<main>'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.3.6/lib/rack/builder.rb:40:in `eval'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.3.6/lib/rack/builder.rb:40:in `parse_file'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.3.6/lib/rack/server.rb:200:in `app'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.3.6/lib/rack/server.rb:301:in `wrapped_app'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.3.6/lib/rack/server.rb:252:in `start'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.3.6/lib/rack/server.rb:137:in `start'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.3.6/bin/rackup:4:in `<top (required)>'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/bin/rackup:23:in `load'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/bin/rackup:23:in `<main>'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `eval'
    from /home/rhh/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `<main>'

private_pub.ru

require "bundler/setup"
require "yaml"
require "faye"
require "private_pub"

Faye::WebSocket.load_adapter('thin')

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

private_pub.yml

development:
  server: "http://localhost:4000/faye"
  secret_token: "secret"
test:
  server: "http://localhost:4000/faye"
  secret_token: "secret"
production:
  server: "http://example.com/faye"
  secret_token: "b4eee1590b9e9eb356be5d7eefba2bb2fd684141aab101738cc8b5ff59e9f04c"
  signature_expiration: 3600 # one hour

Upvotes: 2

Views: 633

Answers (1)

Anil Yadav
Anil Yadav

Reputation: 1096

I not using private pub but i am using faye server for my rails application

Code inside faye.ru

require 'rubygems'
require 'thin'
require 'faye'
faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 45)
run faye_server

You also need to add faye Gem in you gemfile

gem 'faye'
gem 'thin'

Then run this command for start faye sever

faye: bundle exec thin start -R faye.ru -p 9292

For more detail to sending messages using Faye i hope it will help you.

Sorry for my bad English :)

Upvotes: 1

Related Questions