Issues using ratchetphp/Pawl websocket client
<p>My question is specific to using slack rtm on ratchetphp/Pawl. I have below code which connects fine but dies eventually.</p>

<pre><code>            &lt;?php

            require_once "response.php";

            //first make authenticated call to rtm.start    
            use \Curl\Curl;
            $curl = new Curl();

            $rtmStartUrl = "https://slack.com/api/rtm.start?token=xx-xx-xx-xx-xx&amp;pretty=1";
            $curl-&gt;get($rtmStartUrl);

            $wsUrl = $curl-&gt;response-&gt;url;

            $loop = React\EventLoop\Factory::create();
            $connector = new Ratchet\Client\Connector($loop);

            $connector($wsUrl)
            -&gt;then(function(Ratchet\Client\WebSocket $conn) {
            $conn-&gt;on('message', function(\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($conn) {
            echo "Received: {$msg}\n";
            // $conn-&gt;close();
            });

            $conn-&gt;on('close', function($code = null, $reason = null) {
            echo "Connection closed ({$code} - {$reason})\n";
            });

            $conn-&gt;send('Hello World!');
            }, function(\Exception $e) use ($loop) {
            echo "Could not connect: {$e-&gt;getMessage()}\n";
            $loop-&gt;stop();
            });

            $loop-&gt;run();
</code></pre>

<p>Upon running, the output is:</p>

<pre><code>            root@ip-172-31-45-75:/var/www/html/slack# php pawl.php 
            Received: {"type":"hello"}
            Received: {"type":"reconnect_url","url":"wss://mpmulti-qpau.slack-msgs.com/websocket/jDkgDysXfZspRj10zqdcrshHK6PhPLItYx2HEkdXy47RPCAJwKgI_NLq0bhS4uMjIT7iRtOoCDUJffcxcr7YdiqMbITUZYqnTmT39Et5a8JeuPLFfCUUzan4MCz34p0jcfAKaQW9G9HpIWrYH4CTqyICZuhgWHnzo8K7dO2zXFc="}
            Received: {}
            Connection closed (1006 - Underlying connection closed)
            root@ip-172-31-45-75:/var/www/html/slack# 
</code></pre>

<p>The websocket is part of slack rtm api (<a href="https://api.slack.com/rtm" rel="nofollow">https://api.slack.com/rtm</a>). It seems like when reading on empty websocket, the connection is closed. I think it might be like we listen to slack events (<a href="https://api.slack.com/events" rel="nofollow">https://api.slack.com/events</a>) sent over websocket for working to avoid disconnect.</p>

<p>Currently, this does not work because of disconnection error.</p>