title: conn.onmessage function not working in PHP
body: <p>I am working with websocket(Ratchet) with Php(Codeigniter),My &quot;conn.onmessage&quot; function is not working for me,&quot;conn.onopen&quot; function is working but unable to get response(message)
  Here is my code,Where i am wrong ? Thanks in advance.</p>
  <pre><code>&lt;div id=&quot;container&quot;&gt;
        &lt;div id=&quot;body&quot;&gt;
          &lt;div id=&quot;messages&quot;&gt;&lt;/div&gt;
          &lt;input type=&quot;text&quot; id=&quot;text&quot; placeholder=&quot;Message ..&quot;&gt;
          &lt;input type=&quot;text&quot; id=&quot;recipient_id&quot; placeholder=&quot;Recipient id ..&quot;&gt;
          &lt;button id=&quot;submit&quot; value=&quot;POST&quot;&gt;Send&lt;/button&gt;
      &lt;/div&gt;
  
      &lt;p class=&quot;footer&quot;&gt;
          &lt;span style=&quot;float: left;&quot; id=&quot;token&quot;&gt;&lt;/span&gt;
          Page rendered in &lt;strong&gt;{elapsed_time}&lt;/strong&gt;
          seconds. &lt;?php echo (ENVIRONMENT === 'development') ? 'CodeIgniter Version &lt;strong&gt;' . CI_VERSION . '&lt;/strong&gt;' : '' ?&gt;
      &lt;/p&gt;
  &lt;/div&gt;
  &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;script&gt;
      var conn = new WebSocket('ws://localhost:8282');
      var client = {
          user_id: &lt;?php echo $user_id; ?&gt;,
          recipient_id: null,
          type: 'socket',
          token: null,
          message: null
      };
  
      conn.onopen = function (e) {
          console.log(&quot;Connection established!&quot;);
          conn.send(JSON.stringify(client));
          $('#messages').append('&lt;font color=&quot;green&quot;&gt;Successfully connected as user ' + client.user_id + '&lt;/font&gt;&lt;br&gt;');
      };
  
      conn.onmessage = function (e) {
      console.log(&quot;Message recieved !&quot;);
          var data = JSON.parse(e.data);
          if (data.message) {
              $('#messages').append(data.user_id + ' : ' + data.message + '&lt;br&gt;');
          }
          if (data.type === 'token') {
              $('#token').html('JWT Token : ' + data.token);
          }
      };
  
      $('#submit').click(function () {
          
          //alert(&quot;Om Success&quot;);
          
          client.message = $('#text').val();
          client.token = $('#token').text().split(': ')[1];
          client.type = 'chat';
          if ($('#recipient_id').val()) {
              client.recipient_id = $('#recipient_id').val();
          }
          conn.send(JSON.stringify(client));
      });
  &lt;/script&gt;
  </code></pre>