【问题标题】:Sure you're not looking for /faye?确定你不是在寻找 /faye?
【发布时间】:2012-12-10 14:23:01
【问题描述】:

我正在认真学习本教程:

http://net.tutsplus.com/tutorials/ruby/how-to-use-faye-as-a-real-time-push-server-in-rails/

我已经安装了thin,faye,并在faye.ru文件中写了以下内容:

require 'faye'
bayeux = Faye::RackAdapter.new(:mount => '/faye', :timeout => 25)
bayeux.listen(9292)

但是当我启动机架服务器时:

rackup faye.ru -E production -s thin

服务器确实启动正确:

>> Thin web server (v1.5.0 codename Knife)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:9292, CTRL+C to stop

但是当我访问任何网页时,例如“http://localhost:9292/”,我会收到以下消息:

Sure you're not looking for /faye ?

本教程和 Ryan Bates rails cast #260 都没有解释为什么会发生这种情况。有人有想法吗?

我必须说我的项目使用的是 ruby​​ 版本 1.8.7(我无法升级到 1.9,因为我使用的一些 gem 还不支持 1.9)。

【问题讨论】:

  • 好吧,您将 faye 绑定到 /faye,所以上述内容是有道理的。看一下教程,它显示了所有到 /faye 挂载点的交互。其余的东西由你的 Rails 应用程序处理,它在不同的端口上侦听。

标签: ruby-on-rails rack faye


【解决方案1】:

好的,实际上一切正常,我只是不明白 Faye 应该做什么。

Faye 服务器并没有取代 Rails 服务器,而是对其进行了补充。我期待在 localhost:3000 和 localhost:9292 上看到同样的东西。

如果其他人像我一样感到困惑,您必须同时运行两个服务器:

Rails 服务器:

 rails server [with your options if any]

Faye 服务器处理 JS 频道:

 rackup faye.ru -s thin -E production

并且用户仅与 rails 服务器交互(在端口 3000 上)并让 Faye 服务器在后台运行。

【讨论】:

  • 考虑使用 Foreman,这将允许您同时启动它们。
【解决方案2】:

您仍然应该使用端口 3000(除非您更改了默认端口或其他内容)。 9292 只是给 Faye 用的而已。

尝试转到“http://localhost:3000”

【讨论】:

    【解决方案3】:

    输出对我来说看起来不错。

    尝试寻找

    http://localhost:9292/faye.js
    

    而不是

    http://localhost:9292/
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-10
      • 2023-03-24
      • 1970-01-01
      • 2017-05-15
      • 2018-06-11
      • 1970-01-01
      相关资源
      最近更新 更多