Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6975967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:26:11+00:00 2026-05-27T17:26:11+00:00

I am using faye on my Rails 2.1 app. And after testing and fixing

  • 0

I am using faye on my Rails 2.1 app. And after testing and fixing many things faye ruby client is not working.

This is my server code.

require 'faye'

server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 45)


EM.run {
  thin = Rack::Handler.get('thin')
  thin.run(server, :Port => 9292)

  server.bind(:subscribe) do |client_id, channel|
    puts "[  SUBSCRIBE] #{client_id} -> #{channel}"
  end

  server.bind(:unsubscribe) do |client_id, channel|
    puts "[UNSUBSCRIBE] #{client_id} -> #{channel}"
  end

  server.bind(:disconnect) do |client_id|
    puts "[ DISCONNECT] #{client_id}"
  end
}

This is my client side JS code.

<script type="text/javascript">
    var client = new Faye.Client('http://localhost:9292/faye');
    client.subscribe("/faye/new_chats", function(data) {
        console.log(data);
    });
</script>

This is ruby client code.

EM.run do
      client = Faye::Client.new('http://localhost:9292/faye')
      publication = client.publish("/faye/new_chats", {
          "user" => "ruby-logger",
          "message" => "Got your message!"
      })
      publication.callback do
        puts "[PUBLISH SUCCEEDED]"
      end
      publication.errback do |error|
        puts "[PUBLISH FAILED] #{error.inspect}"
      end
    end

Server, JS is working fine. But Ruby client code is not working. If i write it without EM it shows me the error that Event Machine not initialized. If i write it in EM it works but haults the ruby process. If i put EM.stop at the end of client code, it executes but do not publish the message.

How can i solve this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:26:12+00:00Added an answer on May 27, 2026 at 5:26 pm

    I finally used HTTP not the Ruby Faye client as described in railscasts episode 260.

    require 'net/http'
        message = {:channel => '/faye/new_chats', :data => self.text, :ext => {:auth_token => FAYE_TOKEN}}
        uri = URI.parse("http://localhost:9292/faye")
        Net::HTTP.post_form(uri, :message => message.to_json)
    

    It solves my problem.

    NOTE: This solution only works with HTTP but not with HTTPS. If any one find a solution for HTTPS plz update me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently im using PrivatePub(faye) in a rails app for chat but so far every
This doesn't seem to be working right now. I'm using Faye with NodeJS behind
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
I am using Rails + Backbone + Faye to make a sample chat application.
Using ruby(1.8.7) , rails(2.3.8) , rspec(1.3.1) and rspec-rails(1.3.3) how do I test a method
I'm using faye based on this tutorial to create a chat message system. The
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I'm using Faye for dispatching messages and it works well. But I want to
Using the nodejs v.6.7 with faye v.7.1 I am getting error /path/livestats/node_modules/faye0.7/faye.js:18 ID_LENGTH: <%=
Using Rails 3.2.0 with haml and sass: I Would like to link an external

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.