我在2.1.3上一直使用Faye没有问题,但升级到2.2.2后我只能让本地实例工作。生产websockets失败。 我用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
在Rails控制器中
gon.env = Rails.env
听众(Coffeescript)
$ ->
# 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
答案 0 :(得分:0)
所以问题在于Faye的升级。现在开始的语法如下:
rackup --host [服务器的IP地址] faye.ru -s thin -E production -D 现在需要添加 - host [ip address],因为如果没有ip地址,rackup将不再从外部监听。
6天的沮丧,没有关于王菲网站的文件!