title: How to connect a third party socket stream in Laravel
body: <p>I am using spatie and beyondcode's laravel-websockets. I have successfully installed it and able to run to this route by going to /laravel-websockets</p>
  <p><a href="https://i.stack.imgur.com/RGu1L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RGu1L.png" alt="enter image description here" /></a></p>
  <p>My question is how to connect to a third party steam like in python . It seems to be very complicated in laravel with the involvement of Echo (Don't quite understand what is this for ) , Broadcasting and Pusher.</p>
  <p>In python, this is what I do</p>
  <pre><code>import websocket
  SOCKET = &quot;wss://stream.binance.com:9443/ws/btcusdt@kline_1m&quot;
  
  def on_open(ws):
      print(&quot;Open Connection&quot;)
  
  
  def on_close(ws):
      print(&quot;Close Connection&quot;)
  
  def on_message(ws, message):
       print(message)
  
  try:
      ws = websocket.WebSocketApp(
          SOCKET, on_open=on_open, on_close=on_close, on_message=on_message
      )
  except:
      print(&quot;Something went wrong with websocket connection&quot;)
  finally:
      ws.run_forever() //Get Data
  </code></pre>
  <p>How to achieve something similar in Laravel? Can't find anything that mentions how to do such thing in their documentation.</p>