em-websocket icon indicating copy to clipboard operation
em-websocket copied to clipboard

can't connect websocket when start rails with -d.

Open famince opened this issue 6 years ago • 0 comments

it's ok when start rails with command: rails s -b0.0.0.0 -p8080.

but start rails with command:rails s -b0.0.0.0 -p8080 -d can't connect to websocket

server: config/initializers/websocket.rb EM.run { EM::WebSocket.run(:host => "0.0.0.0", :port => 8082) do |ws| ws.onopen { |handshake| puts "WebSocket connection open"

  # Access properties on the EM::WebSocket::Handshake object, e.g.
  # path, query_string, origin, headers

  # Publish message to the client
  ws.send "Hello Client, you connected to #{handshake.path}"
}

ws.onclose { puts "Connection closed" }

ws.onmessage { |msg|
  puts "Recieved message: #{msg}"
  ws.send "Pong: #{msg}"
}

end }

client: html file

websocket test

famince avatar May 18 '19 06:05 famince