I am trying to create a messaging application with Rails 5 ActionCable, but I am getting the above error in the JS console.
ws://localhost:3002/cable' failed: Error during WebSocket handshake: Unexpected response code: 404
I use Redis and Puma jewelry.
I have a Redis server with 7937:M 24 Jul 18:20:53.379 * The server is now ready to accept connections on port 6379
I start the Rails server using Puma: rails s Puma -p 3002(is this even required?)
config/cable.yml looks like that:
development:
adapter: redis
url: redis://localhost:6379
test:
adapter: async
production:
adapter: redis
url: redis://localhost:6379/1
When I enter rails cand I start the broadcast:
2.2.4 :003 > ActionCable.server.broadcast("messages:1", text: "test")
[ActionCable] Broadcasting to messages:1: {:text=>"test"}
=> 0
... you can see that it returns 0, so it fails. And the console error message looks like ...
WebSocket connection to 'ws://localhost:3002/cable' failed: WebSocket is closed before the connection is established.
I'm starting to start when it comes to NGINX. Is this a NGINX problem? If so, how can I solve it? Reconfigure my file nginx.confin /usr/local/etc/nginx/? Currently it looks like this ...
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include servers/*;
}