title: How to send data to laravel echo websocket from client to server
body: <p>I am developing a Laravel app based on Websockets using <code>Laravel Echo</code>.</p>
  
  <p>Everything works fine on the server side, when I send data (through the visual interface of <code>Laravel-Websockets</code> from the browser) they appear in real time in the browser console.</p>
  
  <p>Such that: (client side)</p>
  
  <pre><code>Echo.channel('testchannel')
      .listen('TestEvent', (e) =&gt; {
          console.log(e.message);
      });
  </code></pre>
  
  <p>But then I also want to be able to send data from the client side to the server (as it would be done with the <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send" rel="noreferrer">Websocket:send()</a> method) and for this I use the following line of code:</p>
  
  <pre><code>Echo.connector.socket.emit('App/Events/TestEvent', 'testchannel', {"message":"Hello World"});
  </code></pre>
  
  <p>However, the following error appears in the browser console:</p>
  
  <p><code>TypeError: Echo.connector.socket is undefined</code></p>