Using Websockets

so I’m exploring the world of WebSockets and I’m having some trouble… I’ve been knocking my head against the wall just trying to even get connected… here is a copy of a script I followed from a youtube video and it worked in the video but not mine. every time I run the script it just disconnects. what am I doing wrong.

I have intentionally left out my API keys here…

import config
import websocket, json

def on_open(ws):
auth_data = {
    "action": "authenticate",
    "data": {"key_id": API_KEY, "secret_key": SECRET_KEY}


listen_message = {"action": "listen", "data": {"streams": ["AM.TSLA"]}}


def on_message(ws, message):
print("received a message")

def on_close(ws):
print("closed connection")

socket = "wss://"

ws = websocket.WebSocketApp(socket, on_open=on_open, on_message=on_message, on_close=on_close)

You don’t get a Python interpreter error, do you? When I test your code, I get some output (ref attached screenshot). Is that what you get?


If not, make sure you’ve installed the right websocket library. You want to install ‘websock-client’ …not just ‘websocket’

well, it turns I had to run some Certificates command on my computer… facepalm Thanks for the help guys.