公式のリファレンスを見ながら Heroku で Websockets を使うための方法を書いていきます。
Using WebSockets on Heroku with Node.js
サンプルを clone してくる
git clone https://github.com/heroku-examples/node-ws-test.git
cd node-ws-test
ローカルで試す
npm install
node index.js
ポート 5000 番にアプリケーションが立ち上がるのでブラウザで見てみます。
Heroku にアプリケーションを作成する
heroku create
Heroku に push する
git add .
git commit -m “Ready to deploy“
git push heroku master
作成したアプリケーションにアクセスする
heroku open
ブラウザが開いて、時刻が秒ごとに画面に追記されて出てきたら成功です!