igrigorik / em-websocket

EventMachine based WebSocket server
http://www.igvita.com/2009/12/22/ruby-websockets-tcp-for-the-browser/
MIT License
1.69k stars 187 forks source link

em-websocket wont connect over SSL #142

Open stoivo opened 8 years ago

stoivo commented 8 years ago

em-websocket wont connect over SSL

When trying to connect on secure => false connection is working perfectly but when we try to include tls_options and set secure to true. server just wont start. The EventMachine start but EventMachine::WebSocket start boot and get terminated, but EventMachine is still running as a ruby process. What I mean is that I can find it by running ps aux | grep ruby.

This is the STDOUT we get when we start the process.

Server started
Terminating WebSocket Server

We are using Ruby on rails , nginx server & Ubuntu 12.04, but we don't think that have any thing to do with this issue.

We are using Ruby 2.2.2 eventmachine (1.2.0.1) em-websocket (0.5.1)

for testing purposes we are using letsencrypt for certificates When we setup ssl for https we added these lines to nginx.conf

ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem;
ssl_certificate_key    /etc/letsencrypt/live/domain/privkey.pem;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

This is the websocket script

require 'em-websocket'

EventMachine.run {
  EventMachine::WebSocket.start(
    :host => "0.0.0.0",
    :port => 8080,
    :debug => true,
    :secure => true,
    :tls_options => {
      :private_key_file => "/etc/letsencrypt/live/domain/privkey.pem",
      :cert_chain_file => "/etc/letsencrypt/live/domain/cert.pem",
      :cipher_list => "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"
    }
  ) do |ws|
   puts "Sterting Websocket"
   ws.onopen { |connection|
      puts "onOpen"
    }
  end

  puts "Server started"
}

Thanks for looking at this :) Open issue on https://github.com/eventmachine/eventmachine/issues/733 also, not sure where it belong.