faye

faye ruby client is not working

冷暖自知 提交于 2019-12-03 00:42:59
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

Websocket header missing

故事扮演 提交于 2019-12-02 22:44:22
I'm using the 'faye' gem with Rails 3.2.13. In development I'm running faye on localhost:9292 and my app on localhost:3000. I'm able to activate pop-up windows with a curl request from the command line but I can't establish a connection from within my app. The error I'm getting in my console is: WebSocket connection to 'ws://localhost:9292/faye' failed: Error during WebSocket handshake: 'Upgrade' header is missing I am trying to define a header for faye in my application.js file: $(function() { var faye = new Faye.Client("http://localhost:9292/faye"); faye.setHeader("Access-Control-Allow

Autorun the Faye server when I start the Rails server

家住魔仙堡 提交于 2019-11-28 17:40:33
问题 I currently have Faye working with my Rails 3.0.9 application. However I have two separate tabs open in my terminal. One for the Faye server, and one for the Rails server. How can I integrate them and automatically run the Faye server when Rails starts up? To start the Faye Server, I am running: rackup faye.ru -s thin -E production faye.ru require 'faye' faye_server = Faye::RackAdapter.new(:mount => '/faye') run faye_server Please let me know if you need any more information. 回答1: Simply

sending a javascript object through websockets with faye

僤鯓⒐⒋嵵緔 提交于 2019-11-28 17:00:16
Hi all I'm trying to send a javascript object through websockets: the faye-websockets documentation says: send(message) accepts either a String or a Buffer and sends a text or binary message over the connection to the other peer. server side I'm using node and faye. var WebSocket = require('faye-websocket'); var http = require('http'); var server = http.createServer(); server.addListener('upgrade', function(request, socket, head) { var ws = new WebSocket(request, socket, head); ws.send({topic:'handshake', data:'sdf487rgiuh7'}); }); server.listen(8000); client side: <script> var ws = new

sending a javascript object through websockets with faye

丶灬走出姿态 提交于 2019-11-27 10:19:04
问题 Hi all I'm trying to send a javascript object through websockets: the faye-websockets documentation says: send(message) accepts either a String or a Buffer and sends a text or binary message over the connection to the other peer. server side I'm using node and faye. var WebSocket = require('faye-websocket'); var http = require('http'); var server = http.createServer(); server.addListener('upgrade', function(request, socket, head) { var ws = new WebSocket(request, socket, head); ws.send({topic

How can I push to Faye Server from Rails Controller?

痴心易碎 提交于 2019-11-27 03:49:33
问题 I have this code: def create message = Message.new(text: params[:message][:text], author: params[:message][:author]) if message.save render json: {result: 'success'} else render json: {result: 'failure'} end end I have client subscribed to Faye Server: var subscription = client.subscribe('/foo', function (message) { getMessages(); }); I want to publish some message to Faye when a message is created. As listed in Faye Ruby Sever documentation, I have to do like this: require 'eventmachine' EM