今回はcommand lineでWebSocketを扱えるwscatを試してみたのでメモっておきます
dockerコンテナ立ち上げ
docker run --rm -it -p 8080:8080 --name wscat-test takashioshikawa/php5.6.17
作業ディレクトリ作成
mkdir /src && cd /src
WebSocketテストをダウンロード
wget https://github.com/TakashiOshikawa/ratchet-test/archive/master.zip
解凍
unzip master.zip
cd ratchet-test-master/
node.jsとnpmのインストール
参考はこちら[centos + node.js + npm + nvm インストール]("http://qiita.com/akippiko/items/3708016fc43da088021c" centos + node.js + npm + nvm インストール)
yum install -y epel-release
yum install -y nodejs
yum install -y npm --enablerepo=epel
wscatのインストール
npm install -g wscat
WebSocketアプリの起動とwscatでの接続
WebSocketアプリをバックグラウンドで実行
php bin/chat-server.php &
wscatで接続
wscat -c localhost:8080/chat
こんな感じの文字が出たらOK
[root@ec5ce01ae845 ratchet-test-master]# wscat -c localhost:8080/chat
New connection! (58)
connected (press CTRL+C to quit)
> dd
Connection 58 sending message "dd" to 0 other connections
> aa
Connection 58 sending message "aa" to 0 other connections
>