繁体   English   中英

Faye Websocket错误Rails 2.2.2(生产)

[英]Faye Websocket Error Rails 2.2.2 (production)

我一直在2.1.3上使用Faye没问题,但是升级到2.2.2后,我只能使本地实例正常工作。 生产websocket失败。 我将实际的服务器名称替换为blahblahserver.com

菲·拉克普(Faye Rackup)

require 'faye'
app = Faye::RackAdapter.new(:mount => '/faye', :timeout => 25)
Faye::WebSocket.load_adapter('thin')
run app

Application.html.erb

<%= javascript_include_tag "application",params[:controller],'http://app-server1.blahblahserver.com:9292/faye/faye.js','data-turbolinks-track' => true %>

助手(发送功能)

def broadcast(channel, &block)
  message = {:channel => channel, :data => capture(&block)}
  uri = URI.parse("http://localhost:9292/faye")
  Net::HTTP.post_form(uri, :message => message.to_json)
end

In Rails控制器

gon.env = Rails.env

听众(咖啡)

$ ->
  # required when faye listener is present to keep from having hard env changes
  # parallel gon.env = Rails.env in controller must be present
  server_name = undefined
  switch gon.env
    when "production"
     server_name = 'app-server1.blahblahserver.com'
    when "staging"
     server_name = 'si-staging.blahblahserver.com'
    when "development"
     server_name = 'localhost'
  address = 'http://' + server_name + ':9292/faye'

# Listener for this page locally
faye = new (Faye.Client)(address)
faye.subscribe ('/logs/'+gon.property_id+ '/new'), (data) ->
 if getParameterByName('all_open') == "true"
  window.location.href = window.location.href
 else if  gon.today == gon.display_date
  ready(data)
 else window.location.href = window.location.href
return
faye.subscribe ('/logs/'+gon.property_id+ '/alert'), (data) ->
 console.log('pre-ajax')
 $.ajax 'load_customer_messages' ,
  type: "GET",
  dataType: "JSON",
  asnyc: false,
  success: (data2) ->
    $('#ajax').click()
 return
return

ready = (data) ->
 eval data 

因此,问题出在Faye的升级上。 现在开始的语法如下:

rackup --host [服务器的IP地址] faye.ru -s薄-E生产-D现在需要添加--host [ip地址],因为rackup不再在没有IP地址的情况下进行外部侦听。

6天的挫败感,在faye网站上没有文档!

暂无
暂无

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

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