#๐Ÿ”’ Help just want it to connect to my streamlabs

16 messages ยท Page 1 of 1 (latest)

cloud light
#

best way to summarize this is I'm trying to find out what is causation of this error with socket.io "Failed to connect to Stream labs WebSocket: One or more namespaces failed to connect" i just want to know what am i doing wrong.

import os
import socketio
import asyncio
from dotenv import load_dotenv

load_dotenv()

class StreamlabsConnection:
    def __init__(self):
        self.token = os.getenv("STREAMLABS_SOCKET")
        self.sio = socketio.AsyncClient()
        self.queue = asyncio.Queue()

    async def connect_stream(self):
        @self.sio.on('connect', namespace='/')
        async def connect():
            print("โœ… Connected to Streamlabs")
            await self.sio.emit('authenticate', {"token": self.token}, namespace='/')

        @self.sio.on("event", namespace='/')
        async def on_event(data):
            await self.queue.put(data)

        try:
            await self.sio.connect("https://sockets.streamlabs.com/socket.io/", transports=["websocket"], namespaces=["/"])
        except Exception as e:
            print(f"โŒ Failed to connect to Streamlabs WebSocket: {e}")
            return

        # This keeps the connection alive and continuously yields messages
        while True:
            message = await self.queue.get()
            yield self.parse_message(message)

    def parse_message(self, raw_data):
        event_type = raw_data.get('type', '')
        msg_data = raw_data.get('message', {})
        if isinstance(msg_data, list):
            msg_data = msg_data[0] if msg_data else {}

        return {
            "type": event_type,
            "username": msg_data.get('name') or msg_data.get('from'),
            "message": msg_data.get('message') or msg_data.get('body'),
        }```.
crisp valveBOT
#

@cloud light

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

iron wadi
#

where traceroute

cloud light
#

?

iron wadi
#

full error traceback

cloud light
#

yeah im drawing a blank

iron wadi
#

!trace

crisp valveBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

cloud light
#

i understand that but theres nothing in termnal thats showing which line is a problem

iron wadi
#

well since your using prints and not a logger, Id say put prints at every action to debug your issue..

cloud light
#

ok

iron wadi
#

from what i see tho, namespaves is set to "/" .. is that correct?
i dont use this so i onno, but root "/" doesnt seem like a namedspace its looking for

cloud light
#

at this point im not even postive im using namespace correctly i tried it without and still got the same error

crisp valveBOT
#
Python help channel closed using Discord native close action

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.