Discussions
connecting to websocket using python getting 502 bad gateway
import websocket
import requests
def on_open(ws):
print("Opened connection")
def on_error(wss, err):
print("error", err)
def on_message(ws, msg):
print("MSG: ", msg)
domain = "csgoempire.com"
socketEndpoint = f"wss://trade.{domain}/trade/s"
authorizationToken = "token"
response = requests.get(
f"https://{domain}/api/v2/metadata/socket",
headers={"Authorization": f"Bearer {authorizationToken}"}
)
data = response.json()
userId = data["user"]["id"]
print(f"User ID: {userId}")
print(data["user"]["id"])
ws = websocket.WebSocketApp(f'wss://trade.csgoempire.com/trade/s?EIO=3&transport=websocket', on_open = on_open, on_message = on_message, on_error = on_error, header = {
"User-agent: ", f'{userId} API Bot',
})
ws.run_forever()
tried also with path: wss://trade.csgoempire.com/trade/s/, doesnt seem to work