我正在使用Faye-websocket构建支持实时出价的应用。但我得到了这200个错误,我不知道它是什么问题。
错误:
WebSocket connection to 'ws://localhost/auctions/3' failed: Error during WebSocket handshake: Unexpected response code: 200
SocketConnection.rb
require 'faye/websocket'
要求'websocket / extensions' 要求'线程' 要求'json'
类SocketConnection KEEPALIVE_TIME = 15秒(秒)
def initialize app
@app = app
end
def call env
@env = env
if Faye::WebSocket.websocket?(env)
socket = Faye::WebSocket.new env
socket.ping 'Mic check, one, two' do
p [:ping, socket.object_id, socket.url]
end
socket.on :open do |event|
p [:open, socket.object_id, socket.url]
p [:open, socket.url, socket.version, socket.protocol]
end
socket.rack_response
else
@app.call(env)
end
end
端
答案 0 :(得分:0)
我解决了这个问题。它需要服务器来支持套接字连接。在我的情况下,我使用瘦服务器。所有错误都已修复