3

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

enter image description here

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.

In python, this is what I do

import websocket
SOCKET = "wss://stream.binance.com:9443/ws/btcusdt@kline_1m"

def on_open(ws):
    print("Open Connection")


def on_close(ws):
    print("Close Connection")

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("Something went wrong with websocket connection")
finally:
    ws.run_forever() //Get Data

How to achieve something similar in Laravel? Can't find anything that mentions how to do such thing in their documentation.

desh
  • 627
  • 1
  • 7
  • 19
  • 1
    You got any solution?? I'm also working on the same (binance) in Laravel. – Yash Parekh Sep 06 '21 at 14:37
  • @YashParekh Nope, apparently I raised an ticket with beyond and laravel web-sockets , currently they dont support third party socket stream, – desh Sep 08 '21 at 09:22

0 Answers0