LoginSignup
7

More than 5 years have passed since last update.

Heroku で Websockets with Node.js をはじめるためのメモ

Posted at

公式のリファレンスを見ながら 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

ブラウザが開いて、時刻が秒ごとに画面に追記されて出てきたら成功です!

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7