繁体   English   中英

Faye,Websocket连接问题:无法与ws:// localhost:9292 / faye建立连接

[英]Faye, websocket connection problems: can't establish connection with ws://localhost:9292/faye

我已经设置好Faye服务器,使其与Rails服务器一起运行,就像本教程告诉我的那样: http : //net.tutsplus.com/tutorials/ruby/how-to-use-faye-as-a-real-时间将服务器推入轨道/

没有奇怪的行为,直到我取消注释该行

var client = new Faye.Client('http://localhost:9292/faye');

然后Firebug给我这个问题标题中的错误。 访问localhost:9292 / faye和/faye.js可以得到我期望的结果,并且(显然)引用该.js文件的javascript_include_tag没有任何问题。

我开始faye时,根据此错误消息,我必须使用bundle exec:

$ rackup ./config.ru -E production -s thin -p 9292 /Users/newcreation/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in ``block in setup': You have already activated rack 1.4.1, but your Gemfile requires rack 1.3.0. Using bundle exec may solve this. (Gem::LoadError)

我的config.ru看起来像这样:

require 'rubygems'
require 'bundler'
Bundler.require
require 'faye'

require File.expand_path('../config/initializers/faye_token.rb', __FILE__)

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

有任何想法吗?

谢谢

显然,您至少需要0.7版本才能支持WebSocket。 http://blog.jcoglan.com/2011/11/28/announcing-faye-websocket-a-standards-compatible-websocket-library/对我来说,这意味着更新rubygems,并重新运行捆绑包安装。 我还需要更改.ru文件以包括以下内容:

Faye::WebSocket.load_adapter('thin')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM