We are attempting to deploy DHH's simple Rails 5 chat example to a single, self contained EC2 instance on AWS. Code is available here: https://github.com/HectorPerez/chat-in-rails5
We used Elastic Beanstalk to spin up a single instance thus:
eb create dev-env -p “64bit Amazon Linux 2015.09 v2.0.4 running Ruby
2.2 (Puma)” –single -i t2.micro --envvars
SECRET_KEY_BASE=g5dh9cg614a37d4bdece9126b42d50d0ab8b2fc785daa1e0dac0383d6387f36b
This is a minimal installation, so there is no Elasticache, and no load balancer. To install redis on the EC2 instance we added an .ebextensions config file like this: https://gist.github.com/KeithP/08b38189372b7fd241e5#file-ebextensions-redis-config ; Git commit and deploy.
But the websocket doesnt work: Inspecting the browser console, we see this error repeating over and over:
application-a57354de3399cd895ca366df9bd7316ab69e81d266b63be7d7be563ebc78ab9d.js:27
WebSocket connection to ‘ws://dev-env-y2e5dcrxqk.elasticbeanstalk.com/cable’ failed:
Error during WebSocket handshake: Unexpected response code: 404
The server production.log shows 2 "Started GET /cable" for every "Finished /cable" call.
There are no DEBUG messages from ActiveCable:
/var/app/containerfiles/logs/production.log
-------------------------------------
INFO -- : Processing by RoomsController#show as HTML
DEBUG -- : [1m[36mMessage Load (0.1ms)[0m [1m[34mSELECT "messages".* FROM "messages"[0m INFO -- : Rendered collection (0.0ms)
INFO -- : Rendered rooms/show.html.erb within layouts/application (0.5ms)
INFO -- : Completed 200 OK in 2ms (Views: 1.2ms | ActiveRecord: 0.1ms)
INFO -- : Started GET "/cable" for <ip_address> at 2016-01-01 17:28:26 +0000
INFO -- : Started GET "/cable/" for <ip_address> at 2016-01-01 17:28:26 +0000
INFO -- : Finished "/cable/" for <ip_address> at 2016-01-01 17:28:26 +0000
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…