0

I'm setting up this app that contains a chat module and everything is working fine on localhost.

Now I am trying to connect to the server as a standalone service, but the connection state in the dispatcher is always 'connecting' until it finally times out with the following message:

WebSocket connection to 'ws://myserver:3001/websocket' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

Gemfile

gem 'faye-websocket', '0.10.0'
gem 'websocket-rails', github: 'moaa/websocket-rails', branch: 'threadsocket-rails'
gem 'websocket-rails-js', github: 'websocket-rails/websocket-rails-js', branch: 'sub_protocols'
gem 'puma', group: [:development, :test, :production]

Javascript

var dispatcher = new WebSocketRails(WEBSOCKET_URL);

dispatcher.on_open = function(data) {
    console.log('Connection has been established: ', data);
};

Initializer

WebsocketRails.setup do |config|
    config.log_level = :debug
    config.log_path = "#{Rails.root}/log/websocket_rails.log"
    config.log_internal_events = false
    config.standalone = true
    config.synchronize = false
end

And I am starting the service as explained here: https://github.com/websocket-rails/websocket-rails/issues/302

If I change the URL/Port in the dispatcher, i get different errors. but the one that should work takes like 2 or 3 minutes and then times out.

Have you got any ideas on what could be happening? Is there any special configuration I must set?

Victor Ferreira
  • 6,151
  • 13
  • 64
  • 120
  • I assume you did check the `websocket_rails.log`? Does it not show anything useful? – Raffael May 18 '16 at 00:45
  • Is your live server publishing through port `3001`? - because it might be an issue with routing or request forwarding. i.e., on localhost you're using port `3000` for `http`, but the live server uses port `80` and internally forwards the request to your application's port. If you tried connecting to port `3000` on your production server, your request should fail (the port shouldn't be publicly accessible). – Myst Jun 16 '16 at 01:56
  • P.S. (off-topic) What made you choose `websocket_rails` over Faye or [`plezi.io`](http://www.plezi.io)? Since I'm the author for Plezi, I was wondering what I could improve to make it more accessible. – Myst Jun 16 '16 at 01:59

0 Answers0